feat(db): add stream_sessions model for phase4 on-demand live flow

This commit is contained in:
2026-01-14 15:10:00 +00:00
parent dc65756db8
commit dc9c7df567
3 changed files with 41 additions and 0 deletions

View File

@@ -58,6 +58,21 @@ export const deviceCommands = pgTable('device_commands', {
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(),
});
export const streamSessions = pgTable('stream_sessions', {
id: uuid('id').defaultRandom().primaryKey(),
ownerUserId: uuid('owner_user_id').notNull().references(() => users.id),
cameraDeviceId: uuid('camera_device_id').notNull().references(() => devices.id),
requesterDeviceId: uuid('requester_device_id').notNull().references(() => devices.id),
status: varchar('status', { length: 32 }).default('requested').notNull(),
reason: varchar('reason', { length: 32 }).default('on_demand').notNull(),
streamKey: varchar('stream_key', { length: 255 }),
startedAt: timestamp('started_at', { withTimezone: true }),
endedAt: timestamp('ended_at', { withTimezone: true }),
metadata: jsonb('metadata').$type<Record<string, unknown> | null>().default(null),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(),
});
export const events = pgTable('events', {
id: uuid('id').defaultRandom().primaryKey(),
userId: uuid('user_id').notNull().references(() => users.id),
@@ -139,6 +154,7 @@ export const schema = {
devices,
deviceLinks,
deviceCommands,
streamSessions,
events,
videos,
notifications,