mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-16 19:59:40 +02:00
fix(db): use TEXT for user_id columns across entire codebase
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 <noreply@anthropic.com>
This commit is contained in:
parent
4e63f3f74b
commit
f440ca2a8d
33 changed files with 73 additions and 53 deletions
|
|
@ -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'),
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
|
||||
|
|
|
|||
|
|
@ -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) => ({
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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<string[]>().default([]), // References static quote IDs from shared package
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue