mirror of
https://github.com/soconnor0919/hristudio.git
synced 2026-05-08 13:58:55 -04:00
feat: implement WebSocket for real-time trial updates
- Create standalone WebSocket server (ws-server.ts) on port 3001 using Bun - Add ws_connections table to track active connections in database - Create global WebSocket manager that persists across component unmounts - Fix useWebSocket hook to prevent infinite re-renders and use refs - Fix TrialForm Select components with proper default values - Add trialId to WebSocket URL for server-side tracking - Update package.json with dev:ws script for separate WS server
This commit is contained in:
@@ -485,6 +485,25 @@ export const trials = createTable("trial", {
|
||||
metadata: jsonb("metadata").default({}),
|
||||
});
|
||||
|
||||
export const wsConnections = createTable("ws_connection", {
|
||||
id: uuid("id").notNull().primaryKey().defaultRandom(),
|
||||
trialId: uuid("trial_id")
|
||||
.notNull()
|
||||
.references(() => trials.id, { onDelete: "cascade" }),
|
||||
clientId: text("client_id").notNull().unique(),
|
||||
userId: text("user_id"),
|
||||
connectedAt: timestamp("connected_at", { withTimezone: true })
|
||||
.default(sql`CURRENT_TIMESTAMP`)
|
||||
.notNull(),
|
||||
});
|
||||
|
||||
export const wsConnectionsRelations = relations(wsConnections, ({ one }) => ({
|
||||
trial: one(trials, {
|
||||
fields: [wsConnections.trialId],
|
||||
references: [trials.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
export const steps = createTable(
|
||||
"step",
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user