fix(05-review): CR-02 change endpoint/p256dh to varchar to prevent InnoDB prefix-index truncation

This commit is contained in:
Lucas Berger
2026-06-09 22:24:23 -04:00
parent 82eccc9017
commit 8cecbab7ab
2 changed files with 7 additions and 2 deletions
@@ -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;
+5 -2
View File
@@ -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(),