feat(05-01): add push_subscriptions table + calendar_events.title column; VAPID env wiring
- schema.ts: new pushSubscriptions mysqlTable (user_id FK cascade, endpoint unique, p256dh, auth) - schema.ts: add nullable title varchar(500) to calendarEvents after rawVevent (D-02/NOTIF-01) - 0003_same_xavin.sql: CREATE TABLE push_subscriptions + ALTER calendar_events ADD title - migration applied to dev DB via db:generate + db:migrate (NOT db:push per anti-pattern) - docker-compose.yml: inject VAPID_PUBLIC_KEY/PRIVATE_KEY/SUBJECT into api environment block - .env.example: document all three VAPID vars with placeholders + generation instructions
This commit is contained in:
@@ -119,6 +119,9 @@ export const calendarEvents = mysqlTable(
|
||||
etag: varchar('etag', { length: 256 }),
|
||||
objectUrl: varchar('object_url', { length: 1024 }), // CalDAV object URL; populated from obj.url by sync.ts (D-08)
|
||||
rawVevent: text('raw_vevent').notNull(), // full VCALENDAR/VEVENT string for ical.js
|
||||
// Readable event title extracted from VEVENT SUMMARY by sync.ts (D-02/NOTIF-01).
|
||||
// Nullable: populated by Phase 5 sync update; pre-existing rows remain NULL until resynced.
|
||||
title: varchar('title', { length: 500 }),
|
||||
dtstartUtc: timestamp('dtstart_utc'), // NULL for all-day events
|
||||
dtstartDate: date('dtstart_date'), // set for all-day events; NULL for timed
|
||||
allDay: boolean('all_day').default(false).notNull(),
|
||||
@@ -223,6 +226,33 @@ export const listShares = mysqlTable(
|
||||
],
|
||||
)
|
||||
|
||||
/**
|
||||
* Push notification subscriptions (Phase 5 — Web Push).
|
||||
*
|
||||
* Member-count-agnostic (D-18): one row per browser push subscription endpoint.
|
||||
* endpoint is globally unique — a single device endpoint belongs to exactly one user.
|
||||
* Cascade delete on user removal keeps subscriptions clean without orphan cleanup jobs.
|
||||
*/
|
||||
export const pushSubscriptions = mysqlTable(
|
||||
'push_subscriptions',
|
||||
{
|
||||
id: int().primaryKey().autoincrement(),
|
||||
userId: int('user_id')
|
||||
.notNull()
|
||||
.references(() => users.id, { onDelete: 'cascade' }),
|
||||
endpoint: text('endpoint').notNull(),
|
||||
p256dh: text('p256dh').notNull(),
|
||||
auth: varchar('auth', { length: 256 }).notNull(),
|
||||
createdAt: timestamp('created_at').defaultNow().notNull(),
|
||||
updatedAt: timestamp('updated_at').defaultNow().onUpdateNow(),
|
||||
},
|
||||
(t) => [
|
||||
// One endpoint is globally unique — a single device maps to exactly one subscription row
|
||||
unique('uniq_push_endpoint').on(t.endpoint),
|
||||
index('idx_push_subscriptions_user_id').on(t.userId),
|
||||
],
|
||||
)
|
||||
|
||||
/**
|
||||
* Items within a list.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user