mirror of
https://github.com/SrIzan10/helium.git
synced 2026-06-06 00:56:58 +00:00
feat: move database to postgres
This commit is contained in:
5
app/lib/db/index.ts
Normal file
5
app/lib/db/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { drizzle } from 'drizzle-orm/neon-http';
|
||||
import * as schema from './schema';
|
||||
|
||||
export const db = drizzle(process.env.DATABASE_URL!, { schema });
|
||||
|
||||
23
app/lib/db/schema.ts
Normal file
23
app/lib/db/schema.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { pgTable, text, timestamp, uuid } from 'drizzle-orm/pg-core';
|
||||
|
||||
export const peers = pgTable('peers', {
|
||||
id: text('id').primaryKey(),
|
||||
lastSeen: timestamp('last_seen').notNull().defaultNow(),
|
||||
});
|
||||
|
||||
export const rooms = pgTable('rooms', {
|
||||
id: text('id').primaryKey(),
|
||||
broadcaster: text('broadcaster').notNull().references(() => peers.id, { onDelete: 'cascade' }),
|
||||
createdAt: timestamp('created_at').notNull().defaultNow(),
|
||||
});
|
||||
|
||||
export const roomViewers = pgTable('room_viewers', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
roomId: text('room_id')
|
||||
.notNull()
|
||||
.references(() => rooms.id, { onDelete: 'cascade' }),
|
||||
viewerId: text('viewer_id')
|
||||
.notNull()
|
||||
.references(() => peers.id, { onDelete: 'cascade' }),
|
||||
joinedAt: timestamp('joined_at').notNull().defaultNow(),
|
||||
});
|
||||
@@ -133,7 +133,7 @@ watch(codeRef, (newCode) => {
|
||||
<app-code-input />
|
||||
|
||||
<div class="video relative w-full max-w-1/2 aspect-video">
|
||||
<div v-if="!isConnected" class="absolute inset-0 bg-black flex items-center justify-center z-10">
|
||||
<div v-if="!isConnected" class="absolute inset-0 bg-black flex items-center justify-center z-10 text-white">
|
||||
{{ viewerStore.connectionStatus }}
|
||||
</div>
|
||||
<video
|
||||
|
||||
Reference in New Issue
Block a user