diff --git a/apps/api/src/db/migrations/0004_mature_maximus.sql b/apps/api/src/db/migrations/0004_mature_maximus.sql new file mode 100644 index 0000000..2a9546d --- /dev/null +++ b/apps/api/src/db/migrations/0004_mature_maximus.sql @@ -0,0 +1,2 @@ +ALTER TABLE `push_subscriptions` MODIFY COLUMN `endpoint` varchar(2048) NOT NULL;--> statement-breakpoint +ALTER TABLE `push_subscriptions` MODIFY COLUMN `p256dh` varchar(512) NOT NULL; \ No newline at end of file diff --git a/apps/api/src/db/schema.ts b/apps/api/src/db/schema.ts index c923bac..f239a5a 100644 --- a/apps/api/src/db/schema.ts +++ b/apps/api/src/db/schema.ts @@ -240,8 +240,11 @@ export const pushSubscriptions = mysqlTable( userId: int('user_id') .notNull() .references(() => users.id, { onDelete: 'cascade' }), - endpoint: text('endpoint').notNull(), - p256dh: text('p256dh').notNull(), + // CR-02: varchar(2048) matches the Zod max(2048) bound and avoids the InnoDB + // silent prefix-index truncation that occurs on unbounded text columns. + // varchar(512) for p256dh matches the Zod max(512) bound. + endpoint: varchar('endpoint', { length: 2048 }).notNull(), + p256dh: varchar('p256dh', { length: 512 }).notNull(), auth: varchar('auth', { length: 256 }).notNull(), createdAt: timestamp('created_at').defaultNow().notNull(), updatedAt: timestamp('updated_at').defaultNow().onUpdateNow(),