From f440ca2a8dc7fefea8150243d1df82bc9c9785d7 Mon Sep 17 00:00:00 2001 From: Wuesteon Date: Tue, 9 Dec 2025 16:30:51 +0100 Subject: [PATCH] fix(db): use TEXT for user_id columns across entire codebase MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Better Auth generates non-UUID user IDs (32-char base62 format like 'otUe1YrfENPdHnrF3g1vSBfpkQfambCZ'). Changed all `uuid('user_id')` to `text('user_id')` in Drizzle schemas for consistency with auth system. Affected packages/apps: - apps/calendar, clock, picture, zitare - games/figgos, voxelava - packages/manadeck-database, news-database, uload-database - services/mana-core-auth (feedback schema) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../apps/backend/src/db/schema/calendars.schema.ts | 4 ++-- .../apps/backend/src/db/schema/events.schema.ts | 4 ++-- .../src/db/schema/external-calendars.schema.ts | 4 ++-- .../apps/backend/src/db/schema/reminders.schema.ts | 13 +++++++++++-- .../apps/backend/src/db/schema/alarms.schema.ts | 13 +++++++++++-- .../apps/backend/src/db/schema/presets.schema.ts | 4 ++-- .../apps/backend/src/db/schema/timers.schema.ts | 4 ++-- .../backend/src/db/schema/world-clocks.schema.ts | 4 ++-- .../src/db/schema/batch-generations.schema.ts | 2 +- .../apps/backend/src/db/schema/boards.schema.ts | 2 +- .../src/db/schema/image-generations.schema.ts | 2 +- .../backend/src/db/schema/image-likes.schema.ts | 4 ++-- .../apps/backend/src/db/schema/images.schema.ts | 2 +- .../apps/backend/src/db/schema/favorites.schema.ts | 4 ++-- .../apps/backend/src/db/schema/user-lists.schema.ts | 2 +- docs/MANADECK_POSTGRES_MIGRATION.md | 2 +- .../backend/src/db/schema/figure-likes.schema.ts | 4 ++-- .../apps/backend/src/db/schema/figures.schema.ts | 2 +- .../backend/src/db/schema/level-likes.schema.ts | 4 ++-- .../backend/src/db/schema/level-plays.schema.ts | 4 ++-- .../apps/backend/src/db/schema/levels.schema.ts | 2 +- .../manadeck-database/src/schema/aiGenerations.ts | 4 ++-- .../manadeck-database/src/schema/cardProgress.ts | 3 ++- .../manadeck-database/src/schema/dailyProgress.ts | 4 ++-- packages/manadeck-database/src/schema/decks.ts | 4 ++-- .../manadeck-database/src/schema/studySessions.ts | 4 ++-- packages/manadeck-database/src/schema/userStats.ts | 4 ++-- packages/news-database/src/schema/articles.ts | 2 +- packages/news-database/src/schema/auth.ts | 4 ++-- packages/news-database/src/schema/interactions.ts | 3 ++- packages/uload-database/src/schema/links.ts | 2 +- packages/uload-database/src/schema/tags.ts | 2 +- .../mana-core-auth/src/db/schema/feedback.schema.ts | 4 ++-- 33 files changed, 73 insertions(+), 53 deletions(-) diff --git a/apps/calendar/apps/backend/src/db/schema/calendars.schema.ts b/apps/calendar/apps/backend/src/db/schema/calendars.schema.ts index e4560be55..03da70e7e 100644 --- a/apps/calendar/apps/backend/src/db/schema/calendars.schema.ts +++ b/apps/calendar/apps/backend/src/db/schema/calendars.schema.ts @@ -1,4 +1,4 @@ -import { pgTable, uuid, timestamp, varchar, text, boolean, jsonb } from 'drizzle-orm/pg-core'; +import { pgTable, uuid, text, timestamp, varchar, boolean, jsonb } from 'drizzle-orm/pg-core'; /** * Calendar settings stored in JSONB @@ -16,7 +16,7 @@ export interface CalendarSettings { */ export const calendars = pgTable('calendars', { id: uuid('id').primaryKey().defaultRandom(), - userId: uuid('user_id').notNull(), + userId: text('user_id').notNull(), name: varchar('name', { length: 255 }).notNull(), description: text('description'), color: varchar('color', { length: 7 }).default('#3B82F6'), diff --git a/apps/calendar/apps/backend/src/db/schema/events.schema.ts b/apps/calendar/apps/backend/src/db/schema/events.schema.ts index 0318d408a..746e18397 100644 --- a/apps/calendar/apps/backend/src/db/schema/events.schema.ts +++ b/apps/calendar/apps/backend/src/db/schema/events.schema.ts @@ -1,9 +1,9 @@ import { pgTable, uuid, + text, timestamp, varchar, - text, boolean, jsonb, index, @@ -41,7 +41,7 @@ export const events = pgTable( calendarId: uuid('calendar_id') .notNull() .references(() => calendars.id, { onDelete: 'cascade' }), - userId: uuid('user_id').notNull(), + userId: text('user_id').notNull(), // Basic info title: varchar('title', { length: 500 }).notNull(), diff --git a/apps/calendar/apps/backend/src/db/schema/external-calendars.schema.ts b/apps/calendar/apps/backend/src/db/schema/external-calendars.schema.ts index ab3c04c9e..911ba9d61 100644 --- a/apps/calendar/apps/backend/src/db/schema/external-calendars.schema.ts +++ b/apps/calendar/apps/backend/src/db/schema/external-calendars.schema.ts @@ -1,9 +1,9 @@ import { pgTable, uuid, + text, timestamp, varchar, - text, boolean, jsonb, integer, @@ -27,7 +27,7 @@ export interface ExternalCalendarProviderData { */ export const externalCalendars = pgTable('external_calendars', { id: uuid('id').primaryKey().defaultRandom(), - userId: uuid('user_id').notNull(), + userId: text('user_id').notNull(), // Calendar identification name: varchar('name', { length: 255 }).notNull(), diff --git a/apps/calendar/apps/backend/src/db/schema/reminders.schema.ts b/apps/calendar/apps/backend/src/db/schema/reminders.schema.ts index 45ec1eb54..a41b486ff 100644 --- a/apps/calendar/apps/backend/src/db/schema/reminders.schema.ts +++ b/apps/calendar/apps/backend/src/db/schema/reminders.schema.ts @@ -1,4 +1,13 @@ -import { pgTable, uuid, timestamp, varchar, integer, boolean, index } from 'drizzle-orm/pg-core'; +import { + pgTable, + uuid, + text, + timestamp, + varchar, + integer, + boolean, + index, +} from 'drizzle-orm/pg-core'; import { events } from './events.schema'; /** @@ -11,7 +20,7 @@ export const reminders = pgTable( eventId: uuid('event_id') .notNull() .references(() => events.id, { onDelete: 'cascade' }), - userId: uuid('user_id').notNull(), + userId: text('user_id').notNull(), // Timing minutesBefore: integer('minutes_before').notNull(), diff --git a/apps/clock/apps/backend/src/db/schema/alarms.schema.ts b/apps/clock/apps/backend/src/db/schema/alarms.schema.ts index fa4134970..aea182ed6 100644 --- a/apps/clock/apps/backend/src/db/schema/alarms.schema.ts +++ b/apps/clock/apps/backend/src/db/schema/alarms.schema.ts @@ -1,8 +1,17 @@ -import { pgTable, uuid, varchar, time, boolean, integer, timestamp } from 'drizzle-orm/pg-core'; +import { + pgTable, + uuid, + text, + varchar, + time, + boolean, + integer, + timestamp, +} from 'drizzle-orm/pg-core'; export const alarms = pgTable('alarms', { id: uuid('id').primaryKey().defaultRandom(), - userId: uuid('user_id').notNull(), + userId: text('user_id').notNull(), label: varchar('label', { length: 255 }), time: time('time').notNull(), enabled: boolean('enabled').default(true).notNull(), diff --git a/apps/clock/apps/backend/src/db/schema/presets.schema.ts b/apps/clock/apps/backend/src/db/schema/presets.schema.ts index 680cedf9e..0f5ebf24f 100644 --- a/apps/clock/apps/backend/src/db/schema/presets.schema.ts +++ b/apps/clock/apps/backend/src/db/schema/presets.schema.ts @@ -1,4 +1,4 @@ -import { pgTable, uuid, varchar, integer, jsonb, timestamp } from 'drizzle-orm/pg-core'; +import { pgTable, uuid, text, varchar, integer, jsonb, timestamp } from 'drizzle-orm/pg-core'; export interface PresetSettings { // For pomodoro presets @@ -12,7 +12,7 @@ export interface PresetSettings { export const presets = pgTable('presets', { id: uuid('id').primaryKey().defaultRandom(), - userId: uuid('user_id').notNull(), + userId: text('user_id').notNull(), type: varchar('type', { length: 20 }).notNull(), // 'timer' | 'pomodoro' name: varchar('name', { length: 255 }).notNull(), durationSeconds: integer('duration_seconds').notNull(), diff --git a/apps/clock/apps/backend/src/db/schema/timers.schema.ts b/apps/clock/apps/backend/src/db/schema/timers.schema.ts index 2499698f9..f70308218 100644 --- a/apps/clock/apps/backend/src/db/schema/timers.schema.ts +++ b/apps/clock/apps/backend/src/db/schema/timers.schema.ts @@ -1,8 +1,8 @@ -import { pgTable, uuid, varchar, integer, timestamp } from 'drizzle-orm/pg-core'; +import { pgTable, uuid, text, varchar, integer, timestamp } from 'drizzle-orm/pg-core'; export const timers = pgTable('timers', { id: uuid('id').primaryKey().defaultRandom(), - userId: uuid('user_id').notNull(), + userId: text('user_id').notNull(), label: varchar('label', { length: 255 }), durationSeconds: integer('duration_seconds').notNull(), remainingSeconds: integer('remaining_seconds'), diff --git a/apps/clock/apps/backend/src/db/schema/world-clocks.schema.ts b/apps/clock/apps/backend/src/db/schema/world-clocks.schema.ts index 948f94cc6..b0508865e 100644 --- a/apps/clock/apps/backend/src/db/schema/world-clocks.schema.ts +++ b/apps/clock/apps/backend/src/db/schema/world-clocks.schema.ts @@ -1,8 +1,8 @@ -import { pgTable, uuid, varchar, integer, timestamp } from 'drizzle-orm/pg-core'; +import { pgTable, uuid, text, varchar, integer, timestamp } from 'drizzle-orm/pg-core'; export const worldClocks = pgTable('world_clocks', { id: uuid('id').primaryKey().defaultRandom(), - userId: uuid('user_id').notNull(), + userId: text('user_id').notNull(), timezone: varchar('timezone', { length: 100 }).notNull(), // IANA timezone e.g. 'America/New_York' cityName: varchar('city_name', { length: 255 }).notNull(), sortOrder: integer('sort_order').default(0).notNull(), diff --git a/apps/picture/apps/backend/src/db/schema/batch-generations.schema.ts b/apps/picture/apps/backend/src/db/schema/batch-generations.schema.ts index 7c68115a9..a4cdbe669 100644 --- a/apps/picture/apps/backend/src/db/schema/batch-generations.schema.ts +++ b/apps/picture/apps/backend/src/db/schema/batch-generations.schema.ts @@ -10,7 +10,7 @@ export const batchStatusEnum = pgEnum('batch_status', [ export const batchGenerations = pgTable('batch_generations', { id: uuid('id').primaryKey().defaultRandom(), - userId: uuid('user_id').notNull(), + userId: text('user_id').notNull(), name: text('name'), totalCount: integer('total_count').notNull(), diff --git a/apps/picture/apps/backend/src/db/schema/boards.schema.ts b/apps/picture/apps/backend/src/db/schema/boards.schema.ts index 693be478a..feb3f4449 100644 --- a/apps/picture/apps/backend/src/db/schema/boards.schema.ts +++ b/apps/picture/apps/backend/src/db/schema/boards.schema.ts @@ -2,7 +2,7 @@ import { pgTable, uuid, text, timestamp, boolean, integer } from 'drizzle-orm/pg export const boards = pgTable('boards', { id: uuid('id').primaryKey().defaultRandom(), - userId: uuid('user_id').notNull(), + userId: text('user_id').notNull(), name: text('name').notNull(), description: text('description'), diff --git a/apps/picture/apps/backend/src/db/schema/image-generations.schema.ts b/apps/picture/apps/backend/src/db/schema/image-generations.schema.ts index 093ae48d7..fbe669445 100644 --- a/apps/picture/apps/backend/src/db/schema/image-generations.schema.ts +++ b/apps/picture/apps/backend/src/db/schema/image-generations.schema.ts @@ -11,7 +11,7 @@ export const generationStatusEnum = pgEnum('generation_status', [ export const imageGenerations = pgTable('image_generations', { id: uuid('id').primaryKey().defaultRandom(), - userId: uuid('user_id').notNull(), + userId: text('user_id').notNull(), modelId: uuid('model_id'), batchId: uuid('batch_id'), diff --git a/apps/picture/apps/backend/src/db/schema/image-likes.schema.ts b/apps/picture/apps/backend/src/db/schema/image-likes.schema.ts index 909bb4186..11508e9f2 100644 --- a/apps/picture/apps/backend/src/db/schema/image-likes.schema.ts +++ b/apps/picture/apps/backend/src/db/schema/image-likes.schema.ts @@ -1,4 +1,4 @@ -import { pgTable, uuid, timestamp, unique } from 'drizzle-orm/pg-core'; +import { pgTable, uuid, text, timestamp, unique } from 'drizzle-orm/pg-core'; import { images } from './images.schema'; export const imageLikes = pgTable( @@ -8,7 +8,7 @@ export const imageLikes = pgTable( imageId: uuid('image_id') .notNull() .references(() => images.id, { onDelete: 'cascade' }), - userId: uuid('user_id').notNull(), + userId: text('user_id').notNull(), createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(), }, (table) => ({ diff --git a/apps/picture/apps/backend/src/db/schema/images.schema.ts b/apps/picture/apps/backend/src/db/schema/images.schema.ts index 5cd7d60bd..f9b9e0f9a 100644 --- a/apps/picture/apps/backend/src/db/schema/images.schema.ts +++ b/apps/picture/apps/backend/src/db/schema/images.schema.ts @@ -2,7 +2,7 @@ import { pgTable, uuid, text, timestamp, boolean, integer } from 'drizzle-orm/pg export const images = pgTable('images', { id: uuid('id').primaryKey().defaultRandom(), - userId: uuid('user_id').notNull(), + userId: text('user_id').notNull(), generationId: uuid('generation_id'), sourceImageId: uuid('source_image_id'), diff --git a/apps/zitare/apps/backend/src/db/schema/favorites.schema.ts b/apps/zitare/apps/backend/src/db/schema/favorites.schema.ts index 8f328d121..2f95e65e5 100644 --- a/apps/zitare/apps/backend/src/db/schema/favorites.schema.ts +++ b/apps/zitare/apps/backend/src/db/schema/favorites.schema.ts @@ -1,10 +1,10 @@ -import { pgTable, uuid, timestamp, unique, varchar } from 'drizzle-orm/pg-core'; +import { pgTable, uuid, text, timestamp, unique, varchar } from 'drizzle-orm/pg-core'; export const favorites = pgTable( 'favorites', { id: uuid('id').primaryKey().defaultRandom(), - userId: uuid('user_id').notNull(), + userId: text('user_id').notNull(), quoteId: varchar('quote_id', { length: 100 }).notNull(), // References static quote ID from shared package createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(), }, diff --git a/apps/zitare/apps/backend/src/db/schema/user-lists.schema.ts b/apps/zitare/apps/backend/src/db/schema/user-lists.schema.ts index c0dfb83da..691e142bb 100644 --- a/apps/zitare/apps/backend/src/db/schema/user-lists.schema.ts +++ b/apps/zitare/apps/backend/src/db/schema/user-lists.schema.ts @@ -2,7 +2,7 @@ import { pgTable, uuid, text, timestamp, jsonb } from 'drizzle-orm/pg-core'; export const userLists = pgTable('user_lists', { id: uuid('id').primaryKey().defaultRandom(), - userId: uuid('user_id').notNull(), + userId: text('user_id').notNull(), name: text('name').notNull(), description: text('description'), quoteIds: jsonb('quote_ids').$type().default([]), // References static quote IDs from shared package diff --git a/docs/MANADECK_POSTGRES_MIGRATION.md b/docs/MANADECK_POSTGRES_MIGRATION.md index 5ffd9d8eb..c6275170b 100644 --- a/docs/MANADECK_POSTGRES_MIGRATION.md +++ b/docs/MANADECK_POSTGRES_MIGRATION.md @@ -246,7 +246,7 @@ import { pgTable, uuid, varchar, text, boolean, timestamp, jsonb } from 'drizzle export const decks = pgTable('decks', { id: uuid('id').primaryKey().defaultRandom(), - userId: uuid('user_id').notNull(), + userId: text('user_id').notNull(), // text, not uuid - Better Auth uses non-UUID IDs title: varchar('title', { length: 255 }).notNull(), description: text('description'), coverImageUrl: text('cover_image_url'), diff --git a/games/figgos/apps/backend/src/db/schema/figure-likes.schema.ts b/games/figgos/apps/backend/src/db/schema/figure-likes.schema.ts index 17d8145d3..575759b43 100644 --- a/games/figgos/apps/backend/src/db/schema/figure-likes.schema.ts +++ b/games/figgos/apps/backend/src/db/schema/figure-likes.schema.ts @@ -1,4 +1,4 @@ -import { pgTable, uuid, timestamp, unique } from 'drizzle-orm/pg-core'; +import { pgTable, uuid, text, timestamp, unique } from 'drizzle-orm/pg-core'; import { relations } from 'drizzle-orm'; import { figures } from './figures.schema'; @@ -9,7 +9,7 @@ export const figureLikes = pgTable( figureId: uuid('figure_id') .notNull() .references(() => figures.id, { onDelete: 'cascade' }), - userId: uuid('user_id').notNull(), + userId: text('user_id').notNull(), createdAt: timestamp('created_at').defaultNow(), }, (table) => ({ diff --git a/games/figgos/apps/backend/src/db/schema/figures.schema.ts b/games/figgos/apps/backend/src/db/schema/figures.schema.ts index cb4306d54..e3335ed5e 100644 --- a/games/figgos/apps/backend/src/db/schema/figures.schema.ts +++ b/games/figgos/apps/backend/src/db/schema/figures.schema.ts @@ -12,7 +12,7 @@ export const figures = pgTable('figures', { isPublic: boolean('is_public').default(true), isArchived: boolean('is_archived').default(false), likes: integer('likes').default(0), - userId: uuid('user_id').notNull(), + userId: text('user_id').notNull(), createdAt: timestamp('created_at').defaultNow(), updatedAt: timestamp('updated_at').defaultNow(), }); diff --git a/games/voxelava/apps/backend/src/db/schema/level-likes.schema.ts b/games/voxelava/apps/backend/src/db/schema/level-likes.schema.ts index 680b1e308..002d7484a 100644 --- a/games/voxelava/apps/backend/src/db/schema/level-likes.schema.ts +++ b/games/voxelava/apps/backend/src/db/schema/level-likes.schema.ts @@ -1,4 +1,4 @@ -import { pgTable, uuid, timestamp, unique } from 'drizzle-orm/pg-core'; +import { pgTable, uuid, text, timestamp, unique } from 'drizzle-orm/pg-core'; import { relations } from 'drizzle-orm'; import { levels } from './levels.schema'; @@ -9,7 +9,7 @@ export const levelLikes = pgTable( levelId: uuid('level_id') .notNull() .references(() => levels.id, { onDelete: 'cascade' }), - userId: uuid('user_id').notNull(), + userId: text('user_id').notNull(), createdAt: timestamp('created_at').defaultNow(), }, (table) => ({ diff --git a/games/voxelava/apps/backend/src/db/schema/level-plays.schema.ts b/games/voxelava/apps/backend/src/db/schema/level-plays.schema.ts index 62a272607..d89d2fffe 100644 --- a/games/voxelava/apps/backend/src/db/schema/level-plays.schema.ts +++ b/games/voxelava/apps/backend/src/db/schema/level-plays.schema.ts @@ -1,4 +1,4 @@ -import { pgTable, uuid, timestamp, real, integer, boolean } from 'drizzle-orm/pg-core'; +import { pgTable, uuid, text, timestamp, real, integer, boolean } from 'drizzle-orm/pg-core'; import { relations } from 'drizzle-orm'; import { levels } from './levels.schema'; @@ -7,7 +7,7 @@ export const levelPlays = pgTable('level_plays', { levelId: uuid('level_id') .notNull() .references(() => levels.id, { onDelete: 'cascade' }), - userId: uuid('user_id'), + userId: text('user_id'), completionTime: real('completion_time'), attempts: integer('attempts').default(1), completed: boolean('completed').default(false), diff --git a/games/voxelava/apps/backend/src/db/schema/levels.schema.ts b/games/voxelava/apps/backend/src/db/schema/levels.schema.ts index 65a7c9d67..b7f832ddc 100644 --- a/games/voxelava/apps/backend/src/db/schema/levels.schema.ts +++ b/games/voxelava/apps/backend/src/db/schema/levels.schema.ts @@ -5,7 +5,7 @@ export const levels = pgTable('levels', { id: uuid('id').primaryKey().defaultRandom(), name: text('name').notNull(), description: text('description'), - userId: uuid('user_id').notNull(), + userId: text('user_id').notNull(), voxelData: jsonb('voxel_data').notNull(), spawnPoint: jsonb('spawn_point').notNull(), worldSize: jsonb('world_size').notNull(), diff --git a/packages/manadeck-database/src/schema/aiGenerations.ts b/packages/manadeck-database/src/schema/aiGenerations.ts index c24ff0dfc..ec6f1f823 100644 --- a/packages/manadeck-database/src/schema/aiGenerations.ts +++ b/packages/manadeck-database/src/schema/aiGenerations.ts @@ -1,4 +1,4 @@ -import { pgTable, uuid, varchar, text, timestamp, jsonb, index, pgEnum } from 'drizzle-orm/pg-core'; +import { pgTable, uuid, text, varchar, timestamp, jsonb, index, pgEnum } from 'drizzle-orm/pg-core'; import { relations } from 'drizzle-orm'; import { decks } from './decks.js'; @@ -25,7 +25,7 @@ export const aiGenerations = pgTable( 'ai_generations', { id: uuid('id').primaryKey().defaultRandom(), - userId: uuid('user_id').notNull(), + userId: text('user_id').notNull(), deckId: uuid('deck_id').references(() => decks.id, { onDelete: 'set null' }), functionName: varchar('function_name', { length: 100 }).notNull(), prompt: text('prompt').notNull(), diff --git a/packages/manadeck-database/src/schema/cardProgress.ts b/packages/manadeck-database/src/schema/cardProgress.ts index aedf2618a..d036dc219 100644 --- a/packages/manadeck-database/src/schema/cardProgress.ts +++ b/packages/manadeck-database/src/schema/cardProgress.ts @@ -1,6 +1,7 @@ import { pgTable, uuid, + text, integer, timestamp, index, @@ -23,7 +24,7 @@ export const cardProgress = pgTable( 'card_progress', { id: uuid('id').primaryKey().defaultRandom(), - userId: uuid('user_id').notNull(), + userId: text('user_id').notNull(), cardId: uuid('card_id') .notNull() .references(() => cards.id, { onDelete: 'cascade' }), diff --git a/packages/manadeck-database/src/schema/dailyProgress.ts b/packages/manadeck-database/src/schema/dailyProgress.ts index 62e4be18f..20bca5683 100644 --- a/packages/manadeck-database/src/schema/dailyProgress.ts +++ b/packages/manadeck-database/src/schema/dailyProgress.ts @@ -1,10 +1,10 @@ import { pgTable, uuid, + text, date, integer, decimal, - text, timestamp, index, unique, @@ -14,7 +14,7 @@ export const dailyProgress = pgTable( 'daily_progress', { id: uuid('id').primaryKey().defaultRandom(), - userId: uuid('user_id').notNull(), + userId: text('user_id').notNull(), date: date('date').notNull(), cardsStudied: integer('cards_studied').default(0).notNull(), timeSpentMinutes: integer('time_spent_minutes').default(0).notNull(), diff --git a/packages/manadeck-database/src/schema/decks.ts b/packages/manadeck-database/src/schema/decks.ts index 96085c4f9..7644cf09d 100644 --- a/packages/manadeck-database/src/schema/decks.ts +++ b/packages/manadeck-database/src/schema/decks.ts @@ -1,8 +1,8 @@ import { pgTable, uuid, - varchar, text, + varchar, boolean, timestamp, jsonb, @@ -17,7 +17,7 @@ export const decks = pgTable( 'decks', { id: uuid('id').primaryKey().defaultRandom(), - userId: uuid('user_id').notNull(), + userId: text('user_id').notNull(), title: varchar('title', { length: 255 }).notNull(), description: text('description'), coverImageUrl: text('cover_image_url'), diff --git a/packages/manadeck-database/src/schema/studySessions.ts b/packages/manadeck-database/src/schema/studySessions.ts index dd7b2029a..abb0f4c0c 100644 --- a/packages/manadeck-database/src/schema/studySessions.ts +++ b/packages/manadeck-database/src/schema/studySessions.ts @@ -1,4 +1,4 @@ -import { pgTable, uuid, integer, timestamp, index, pgEnum } from 'drizzle-orm/pg-core'; +import { pgTable, uuid, text, integer, timestamp, index, pgEnum } from 'drizzle-orm/pg-core'; import { relations } from 'drizzle-orm'; import { decks } from './decks.js'; @@ -12,7 +12,7 @@ export const studySessions = pgTable( deckId: uuid('deck_id') .notNull() .references(() => decks.id, { onDelete: 'cascade' }), - userId: uuid('user_id').notNull(), + userId: text('user_id').notNull(), mode: studyModeEnum('mode').notNull(), totalCards: integer('total_cards').notNull().default(0), completedCards: integer('completed_cards').notNull().default(0), diff --git a/packages/manadeck-database/src/schema/userStats.ts b/packages/manadeck-database/src/schema/userStats.ts index c0df42432..bcb448fb8 100644 --- a/packages/manadeck-database/src/schema/userStats.ts +++ b/packages/manadeck-database/src/schema/userStats.ts @@ -1,9 +1,9 @@ -import { pgTable, uuid, integer, decimal, date, timestamp, index } from 'drizzle-orm/pg-core'; +import { pgTable, text, integer, decimal, date, timestamp, index } from 'drizzle-orm/pg-core'; export const userStats = pgTable( 'user_stats', { - userId: uuid('user_id').primaryKey(), + userId: text('user_id').primaryKey(), totalWins: integer('total_wins').default(0).notNull(), totalSessions: integer('total_sessions').default(0).notNull(), totalCardsStudied: integer('total_cards_studied').default(0).notNull(), diff --git a/packages/news-database/src/schema/articles.ts b/packages/news-database/src/schema/articles.ts index e9f2e26d5..fd4664d3d 100644 --- a/packages/news-database/src/schema/articles.ts +++ b/packages/news-database/src/schema/articles.ts @@ -29,7 +29,7 @@ export const articles = pgTable( summary: text('summary'), // For user-saved articles - userId: uuid('user_id').references(() => users.id, { onDelete: 'cascade' }), + userId: text('user_id').references(() => users.id, { onDelete: 'cascade' }), originalUrl: text('original_url'), parsedContent: text('parsed_content'), isArchived: boolean('is_archived').default(false), diff --git a/packages/news-database/src/schema/auth.ts b/packages/news-database/src/schema/auth.ts index ba40bc52d..1e3309b86 100644 --- a/packages/news-database/src/schema/auth.ts +++ b/packages/news-database/src/schema/auth.ts @@ -4,7 +4,7 @@ import { users } from './users'; // Better Auth Sessions export const sessions = pgTable('sessions', { id: uuid('id').primaryKey().defaultRandom(), - userId: uuid('user_id') + userId: text('user_id') .references(() => users.id, { onDelete: 'cascade' }) .notNull(), token: text('token').notNull().unique(), @@ -18,7 +18,7 @@ export const sessions = pgTable('sessions', { // Better Auth Accounts (for OAuth providers) export const accounts = pgTable('accounts', { id: uuid('id').primaryKey().defaultRandom(), - userId: uuid('user_id') + userId: text('user_id') .references(() => users.id, { onDelete: 'cascade' }) .notNull(), providerId: text('provider_id').notNull(), // 'credential', 'google', 'apple', etc. diff --git a/packages/news-database/src/schema/interactions.ts b/packages/news-database/src/schema/interactions.ts index a69d077b9..49bfef56a 100644 --- a/packages/news-database/src/schema/interactions.ts +++ b/packages/news-database/src/schema/interactions.ts @@ -1,6 +1,7 @@ import { pgTable, uuid, + text, timestamp, boolean, real, @@ -15,7 +16,7 @@ export const userArticleInteractions = pgTable( 'user_article_interactions', { id: uuid('id').primaryKey().defaultRandom(), - userId: uuid('user_id') + userId: text('user_id') .references(() => users.id, { onDelete: 'cascade' }) .notNull(), articleId: uuid('article_id') diff --git a/packages/uload-database/src/schema/links.ts b/packages/uload-database/src/schema/links.ts index 059f4e562..7168756eb 100644 --- a/packages/uload-database/src/schema/links.ts +++ b/packages/uload-database/src/schema/links.ts @@ -21,7 +21,7 @@ export const links = pgTable( originalUrl: text('original_url').notNull(), title: text('title'), description: text('description'), - userId: uuid('user_id').references(() => users.id, { onDelete: 'cascade' }), + userId: text('user_id').references(() => users.id, { onDelete: 'cascade' }), isActive: boolean('is_active').default(true), password: text('password'), // hashed maxClicks: integer('max_clicks'), diff --git a/packages/uload-database/src/schema/tags.ts b/packages/uload-database/src/schema/tags.ts index c4152ecd1..e85e646b0 100644 --- a/packages/uload-database/src/schema/tags.ts +++ b/packages/uload-database/src/schema/tags.ts @@ -12,7 +12,7 @@ export const tags = pgTable( icon: text('icon'), isPublic: boolean('is_public').default(false), usageCount: integer('usage_count').default(0), - userId: uuid('user_id').references(() => users.id), + userId: text('user_id').references(() => users.id), createdAt: timestamp('created_at').defaultNow().notNull(), updatedAt: timestamp('updated_at').defaultNow().notNull(), }, diff --git a/services/mana-core-auth/src/db/schema/feedback.schema.ts b/services/mana-core-auth/src/db/schema/feedback.schema.ts index b16ed5ada..7987e37ca 100644 --- a/services/mana-core-auth/src/db/schema/feedback.schema.ts +++ b/services/mana-core-auth/src/db/schema/feedback.schema.ts @@ -38,7 +38,7 @@ export const userFeedback = feedbackSchema.table( 'user_feedback', { id: uuid('id').primaryKey().defaultRandom(), - userId: uuid('user_id') + userId: text('user_id') .references(() => users.id, { onDelete: 'cascade' }) .notNull(), appId: text('app_id').notNull(), // 'chat', 'picture', 'zitare', etc. @@ -82,7 +82,7 @@ export const feedbackVotes = feedbackSchema.table( feedbackId: uuid('feedback_id') .references(() => userFeedback.id, { onDelete: 'cascade' }) .notNull(), - userId: uuid('user_id') + userId: text('user_id') .references(() => users.id, { onDelete: 'cascade' }) .notNull(), createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),