refactor(cleanup): remove Turso/Drizzle database files
- commit
- 59801edc5e0b4a2957427fc809ba5931a93c23cc
- author
- bnema · · 2026-01-18 18:35 UTC
- parent
- adc9504
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
11 files · +0 -1118
D drizzle.config.ts +0 -12
| @@ -1,12 +0,0 @@ | |||
| 1 | - | import 'dotenv/config'; | |
| 2 | - | import { defineConfig } from 'drizzle-kit'; | |
| 3 | - | ||
| 4 | - | export default defineConfig({ | |
| 5 | - | out: './drizzle', | |
| 6 | - | schema: './src/lib/db/schema.ts', | |
| 7 | - | dialect: 'turso', | |
| 8 | - | dbCredentials: { | |
| 9 | - | url: process.env.TURSO_DATABASE_URL as string, | |
| 10 | - | authToken: process.env.TURSO_AUTH_TOKEN as string | |
| 11 | - | } | |
| 12 | - | }); | |
| @@ -1,12 +0,0 @@ | |||||
| 1 | - | import 'dotenv/config'; | |||
| 2 | - | import { defineConfig } from 'drizzle-kit'; | |||
| 3 | - | ||||
| 4 | - | export default defineConfig({ | |||
| 5 | - | out: './drizzle', | |||
| 6 | - | schema: './src/lib/db/schema.ts', | |||
| 7 | - | dialect: 'turso', | |||
| 8 | - | dbCredentials: { | |||
| 9 | - | url: process.env.TURSO_DATABASE_URL as string, | |||
| 10 | - | authToken: process.env.TURSO_AUTH_TOKEN as string | |||
| 11 | - | } | |||
| 12 | - | }); | |||
D drizzle/0000_shallow_ghost_rider.sql +0 -33
| @@ -1,33 +0,0 @@ | |||
| 1 | - | CREATE TABLE `chat_rooms` ( | |
| 2 | - | `id` text PRIMARY KEY NOT NULL, | |
| 3 | - | `name` text, | |
| 4 | - | `type` text DEFAULT 'direct' NOT NULL, | |
| 5 | - | `created_at` integer NOT NULL | |
| 6 | - | ); | |
| 7 | - | --> statement-breakpoint | |
| 8 | - | CREATE TABLE `messages` ( | |
| 9 | - | `id` text PRIMARY KEY NOT NULL, | |
| 10 | - | `chat_room_id` text NOT NULL, | |
| 11 | - | `sender_id` text NOT NULL, | |
| 12 | - | `content` text NOT NULL, | |
| 13 | - | `type` text DEFAULT 'chat' NOT NULL, | |
| 14 | - | `timestamp` integer NOT NULL, | |
| 15 | - | FOREIGN KEY (`chat_room_id`) REFERENCES `chat_rooms`(`id`) ON UPDATE no action ON DELETE no action, | |
| 16 | - | FOREIGN KEY (`sender_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action | |
| 17 | - | ); | |
| 18 | - | --> statement-breakpoint | |
| 19 | - | CREATE TABLE `users` ( | |
| 20 | - | `id` text PRIMARY KEY NOT NULL, | |
| 21 | - | `email` text NOT NULL, | |
| 22 | - | `password` text NOT NULL, | |
| 23 | - | `nickname` text NOT NULL, | |
| 24 | - | `status` text DEFAULT 'offline', | |
| 25 | - | `avatar_url` text, | |
| 26 | - | `created_at` integer NOT NULL, | |
| 27 | - | `last_seen` integer | |
| 28 | - | ); | |
| 29 | - | --> statement-breakpoint | |
| 30 | - | CREATE UNIQUE INDEX `users_email_unique` ON `users` (`email`);--> statement-breakpoint | |
| 31 | - | CREATE VIEW `chat_room_view` AS select "id", "name", "type", "created_at" from "chat_rooms";--> statement-breakpoint | |
| 32 | - | CREATE VIEW `message_view` AS select "messages"."id", "messages"."content", "messages"."type", "messages"."timestamp", "users"."nickname", "chat_rooms"."name" from "messages" left join "users" on "messages"."sender_id" = "users"."id" left join "chat_rooms" on "messages"."chat_room_id" = "chat_rooms"."id";--> statement-breakpoint | |
| 33 | - | CREATE VIEW `user_view` AS select "id", "nickname", "status", "avatar_url", "last_seen" from "users";⏎̸ | |
| @@ -1,33 +0,0 @@ | |||||
| 1 | - | CREATE TABLE `chat_rooms` ( | |||
| 2 | - | `id` text PRIMARY KEY NOT NULL, | |||
| 3 | - | `name` text, | |||
| 4 | - | `type` text DEFAULT 'direct' NOT NULL, | |||
| 5 | - | `created_at` integer NOT NULL | |||
| 6 | - | ); | |||
| 7 | - | --> statement-breakpoint | |||
| 8 | - | CREATE TABLE `messages` ( | |||
| 9 | - | `id` text PRIMARY KEY NOT NULL, | |||
| 10 | - | `chat_room_id` text NOT NULL, | |||
| 11 | - | `sender_id` text NOT NULL, | |||
| 12 | - | `content` text NOT NULL, | |||
| 13 | - | `type` text DEFAULT 'chat' NOT NULL, | |||
| 14 | - | `timestamp` integer NOT NULL, | |||
| 15 | - | FOREIGN KEY (`chat_room_id`) REFERENCES `chat_rooms`(`id`) ON UPDATE no action ON DELETE no action, | |||
| 16 | - | FOREIGN KEY (`sender_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action | |||
| 17 | - | ); | |||
| 18 | - | --> statement-breakpoint | |||
| 19 | - | CREATE TABLE `users` ( | |||
| 20 | - | `id` text PRIMARY KEY NOT NULL, | |||
| 21 | - | `email` text NOT NULL, | |||
| 22 | - | `password` text NOT NULL, | |||
| 23 | - | `nickname` text NOT NULL, | |||
| 24 | - | `status` text DEFAULT 'offline', | |||
| 25 | - | `avatar_url` text, | |||
| 26 | - | `created_at` integer NOT NULL, | |||
| 27 | - | `last_seen` integer | |||
| 28 | - | ); | |||
| 29 | - | --> statement-breakpoint | |||
| 30 | - | CREATE UNIQUE INDEX `users_email_unique` ON `users` (`email`);--> statement-breakpoint | |||
| 31 | - | CREATE VIEW `chat_room_view` AS select "id", "name", "type", "created_at" from "chat_rooms";--> statement-breakpoint | |||
| 32 | - | CREATE VIEW `message_view` AS select "messages"."id", "messages"."content", "messages"."type", "messages"."timestamp", "users"."nickname", "chat_rooms"."name" from "messages" left join "users" on "messages"."sender_id" = "users"."id" left join "chat_rooms" on "messages"."chat_room_id" = "chat_rooms"."id";--> statement-breakpoint | |||
| 33 | - | CREATE VIEW `user_view` AS select "id", "nickname", "status", "avatar_url", "last_seen" from "users";⏎̸ | |||
D drizzle/0001_blushing_jean_grey.sql +0 -11
| @@ -1,11 +0,0 @@ | |||
| 1 | - | CREATE TABLE `sessions` ( | |
| 2 | - | `id` text PRIMARY KEY NOT NULL, | |
| 3 | - | `user_id` text NOT NULL, | |
| 4 | - | `expires_at` integer NOT NULL, | |
| 5 | - | `created_at` integer NOT NULL, | |
| 6 | - | FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action | |
| 7 | - | ); | |
| 8 | - | --> statement-breakpoint | |
| 9 | - | DROP INDEX `users_email_unique`;--> statement-breakpoint | |
| 10 | - | ALTER TABLE `users` ALTER COLUMN "status" TO "status" text NOT NULL DEFAULT 'offline';--> statement-breakpoint | |
| 11 | - | ALTER TABLE `users` DROP COLUMN `email`;⏎̸ | |
| @@ -1,11 +0,0 @@ | |||||
| 1 | - | CREATE TABLE `sessions` ( | |||
| 2 | - | `id` text PRIMARY KEY NOT NULL, | |||
| 3 | - | `user_id` text NOT NULL, | |||
| 4 | - | `expires_at` integer NOT NULL, | |||
| 5 | - | `created_at` integer NOT NULL, | |||
| 6 | - | FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action | |||
| 7 | - | ); | |||
| 8 | - | --> statement-breakpoint | |||
| 9 | - | DROP INDEX `users_email_unique`;--> statement-breakpoint | |||
| 10 | - | ALTER TABLE `users` ALTER COLUMN "status" TO "status" text NOT NULL DEFAULT 'offline';--> statement-breakpoint | |||
| 11 | - | ALTER TABLE `users` DROP COLUMN `email`;⏎̸ | |||
D drizzle/meta/0000_snapshot.json +0 -332
| @@ -1,332 +0,0 @@ | |||
| 1 | - | { | |
| 2 | - | "version": "6", | |
| 3 | - | "dialect": "sqlite", | |
| 4 | - | "id": "16b13426-2b9d-4084-8e17-71f9de0f72d0", | |
| 5 | - | "prevId": "00000000-0000-0000-0000-000000000000", | |
| 6 | - | "tables": { | |
| 7 | - | "chat_rooms": { | |
| 8 | - | "name": "chat_rooms", | |
| 9 | - | "columns": { | |
| 10 | - | "id": { | |
| 11 | - | "name": "id", | |
| 12 | - | "type": "text", | |
| 13 | - | "primaryKey": true, | |
| 14 | - | "notNull": true, | |
| 15 | - | "autoincrement": false | |
| 16 | - | }, | |
| 17 | - | "name": { | |
| 18 | - | "name": "name", | |
| 19 | - | "type": "text", | |
| 20 | - | "primaryKey": false, | |
| 21 | - | "notNull": false, | |
| 22 | - | "autoincrement": false | |
| 23 | - | }, | |
| 24 | - | "type": { | |
| 25 | - | "name": "type", | |
| 26 | - | "type": "text", | |
| 27 | - | "primaryKey": false, | |
| 28 | - | "notNull": true, | |
| 29 | - | "autoincrement": false, | |
| 30 | - | "default": "'direct'" | |
| 31 | - | }, | |
| 32 | - | "created_at": { | |
| 33 | - | "name": "created_at", | |
| 34 | - | "type": "integer", | |
| 35 | - | "primaryKey": false, | |
| 36 | - | "notNull": true, | |
| 37 | - | "autoincrement": false | |
| 38 | - | } | |
| 39 | - | }, | |
| 40 | - | "indexes": {}, | |
| 41 | - | "foreignKeys": {}, | |
| 42 | - | "compositePrimaryKeys": {}, | |
| 43 | - | "uniqueConstraints": {}, | |
| 44 | - | "checkConstraints": {} | |
| 45 | - | }, | |
| 46 | - | "messages": { | |
| 47 | - | "name": "messages", | |
| 48 | - | "columns": { | |
| 49 | - | "id": { | |
| 50 | - | "name": "id", | |
| 51 | - | "type": "text", | |
| 52 | - | "primaryKey": true, | |
| 53 | - | "notNull": true, | |
| 54 | - | "autoincrement": false | |
| 55 | - | }, | |
| 56 | - | "chat_room_id": { | |
| 57 | - | "name": "chat_room_id", | |
| 58 | - | "type": "text", | |
| 59 | - | "primaryKey": false, | |
| 60 | - | "notNull": true, | |
| 61 | - | "autoincrement": false | |
| 62 | - | }, | |
| 63 | - | "sender_id": { | |
| 64 | - | "name": "sender_id", | |
| 65 | - | "type": "text", | |
| 66 | - | "primaryKey": false, | |
| 67 | - | "notNull": true, | |
| 68 | - | "autoincrement": false | |
| 69 | - | }, | |
| 70 | - | "content": { | |
| 71 | - | "name": "content", | |
| 72 | - | "type": "text", | |
| 73 | - | "primaryKey": false, | |
| 74 | - | "notNull": true, | |
| 75 | - | "autoincrement": false | |
| 76 | - | }, | |
| 77 | - | "type": { | |
| 78 | - | "name": "type", | |
| 79 | - | "type": "text", | |
| 80 | - | "primaryKey": false, | |
| 81 | - | "notNull": true, | |
| 82 | - | "autoincrement": false, | |
| 83 | - | "default": "'chat'" | |
| 84 | - | }, | |
| 85 | - | "timestamp": { | |
| 86 | - | "name": "timestamp", | |
| 87 | - | "type": "integer", | |
| 88 | - | "primaryKey": false, | |
| 89 | - | "notNull": true, | |
| 90 | - | "autoincrement": false | |
| 91 | - | } | |
| 92 | - | }, | |
| 93 | - | "indexes": {}, | |
| 94 | - | "foreignKeys": { | |
| 95 | - | "messages_chat_room_id_chat_rooms_id_fk": { | |
| 96 | - | "name": "messages_chat_room_id_chat_rooms_id_fk", | |
| 97 | - | "tableFrom": "messages", | |
| 98 | - | "tableTo": "chat_rooms", | |
| 99 | - | "columnsFrom": ["chat_room_id"], | |
| 100 | - | "columnsTo": ["id"], | |
| 101 | - | "onDelete": "no action", | |
| 102 | - | "onUpdate": "no action" | |
| 103 | - | }, | |
| 104 | - | "messages_sender_id_users_id_fk": { | |
| 105 | - | "name": "messages_sender_id_users_id_fk", | |
| 106 | - | "tableFrom": "messages", | |
| 107 | - | "tableTo": "users", | |
| 108 | - | "columnsFrom": ["sender_id"], | |
| 109 | - | "columnsTo": ["id"], | |
| 110 | - | "onDelete": "no action", | |
| 111 | - | "onUpdate": "no action" | |
| 112 | - | } | |
| 113 | - | }, | |
| 114 | - | "compositePrimaryKeys": {}, | |
| 115 | - | "uniqueConstraints": {}, | |
| 116 | - | "checkConstraints": {} | |
| 117 | - | }, | |
| 118 | - | "users": { | |
| 119 | - | "name": "users", | |
| 120 | - | "columns": { | |
| 121 | - | "id": { | |
| 122 | - | "name": "id", | |
| 123 | - | "type": "text", | |
| 124 | - | "primaryKey": true, | |
| 125 | - | "notNull": true, | |
| 126 | - | "autoincrement": false | |
| 127 | - | }, | |
| 128 | - | "email": { | |
| 129 | - | "name": "email", | |
| 130 | - | "type": "text", | |
| 131 | - | "primaryKey": false, | |
| 132 | - | "notNull": true, | |
| 133 | - | "autoincrement": false | |
| 134 | - | }, | |
| 135 | - | "password": { | |
| 136 | - | "name": "password", | |
| 137 | - | "type": "text", | |
| 138 | - | "primaryKey": false, | |
| 139 | - | "notNull": true, | |
| 140 | - | "autoincrement": false | |
| 141 | - | }, | |
| 142 | - | "nickname": { | |
| 143 | - | "name": "nickname", | |
| 144 | - | "type": "text", | |
| 145 | - | "primaryKey": false, | |
| 146 | - | "notNull": true, | |
| 147 | - | "autoincrement": false | |
| 148 | - | }, | |
| 149 | - | "status": { | |
| 150 | - | "name": "status", | |
| 151 | - | "type": "text", | |
| 152 | - | "primaryKey": false, | |
| 153 | - | "notNull": false, | |
| 154 | - | "autoincrement": false, | |
| 155 | - | "default": "'offline'" | |
| 156 | - | }, | |
| 157 | - | "avatar_url": { | |
| 158 | - | "name": "avatar_url", | |
| 159 | - | "type": "text", | |
| 160 | - | "primaryKey": false, | |
| 161 | - | "notNull": false, | |
| 162 | - | "autoincrement": false | |
| 163 | - | }, | |
| 164 | - | "created_at": { | |
| 165 | - | "name": "created_at", | |
| 166 | - | "type": "integer", | |
| 167 | - | "primaryKey": false, | |
| 168 | - | "notNull": true, | |
| 169 | - | "autoincrement": false | |
| 170 | - | }, | |
| 171 | - | "last_seen": { | |
| 172 | - | "name": "last_seen", | |
| 173 | - | "type": "integer", | |
| 174 | - | "primaryKey": false, | |
| 175 | - | "notNull": false, | |
| 176 | - | "autoincrement": false | |
| 177 | - | } | |
| 178 | - | }, | |
| 179 | - | "indexes": { | |
| 180 | - | "users_email_unique": { | |
| 181 | - | "name": "users_email_unique", | |
| 182 | - | "columns": ["email"], | |
| 183 | - | "isUnique": true | |
| 184 | - | } | |
| 185 | - | }, | |
| 186 | - | "foreignKeys": {}, | |
| 187 | - | "compositePrimaryKeys": {}, | |
| 188 | - | "uniqueConstraints": {}, | |
| 189 | - | "checkConstraints": {} | |
| 190 | - | } | |
| 191 | - | }, | |
| 192 | - | "views": { | |
| 193 | - | "chat_room_view": { | |
| 194 | - | "columns": { | |
| 195 | - | "id": { | |
| 196 | - | "name": "id", | |
| 197 | - | "type": "text", | |
| 198 | - | "primaryKey": true, | |
| 199 | - | "notNull": true, | |
| 200 | - | "autoincrement": false | |
| 201 | - | }, | |
| 202 | - | "name": { | |
| 203 | - | "name": "name", | |
| 204 | - | "type": "text", | |
| 205 | - | "primaryKey": false, | |
| 206 | - | "notNull": false, | |
| 207 | - | "autoincrement": false | |
| 208 | - | }, | |
| 209 | - | "type": { | |
| 210 | - | "name": "type", | |
| 211 | - | "type": "text", | |
| 212 | - | "primaryKey": false, | |
| 213 | - | "notNull": true, | |
| 214 | - | "autoincrement": false, | |
| 215 | - | "default": "'direct'" | |
| 216 | - | }, | |
| 217 | - | "created_at": { | |
| 218 | - | "name": "created_at", | |
| 219 | - | "type": "integer", | |
| 220 | - | "primaryKey": false, | |
| 221 | - | "notNull": true, | |
| 222 | - | "autoincrement": false | |
| 223 | - | } | |
| 224 | - | }, | |
| 225 | - | "name": "chat_room_view", | |
| 226 | - | "isExisting": false, | |
| 227 | - | "definition": "select \"id\", \"name\", \"type\", \"created_at\" from \"chat_rooms\"" | |
| 228 | - | }, | |
| 229 | - | "message_view": { | |
| 230 | - | "columns": { | |
| 231 | - | "id": { | |
| 232 | - | "name": "id", | |
| 233 | - | "type": "text", | |
| 234 | - | "primaryKey": true, | |
| 235 | - | "notNull": true, | |
| 236 | - | "autoincrement": false | |
| 237 | - | }, | |
| 238 | - | "content": { | |
| 239 | - | "name": "content", | |
| 240 | - | "type": "text", | |
| 241 | - | "primaryKey": false, | |
| 242 | - | "notNull": true, | |
| 243 | - | "autoincrement": false | |
| 244 | - | }, | |
| 245 | - | "type": { | |
| 246 | - | "name": "type", | |
| 247 | - | "type": "text", | |
| 248 | - | "primaryKey": false, | |
| 249 | - | "notNull": true, | |
| 250 | - | "autoincrement": false, | |
| 251 | - | "default": "'chat'" | |
| 252 | - | }, | |
| 253 | - | "timestamp": { | |
| 254 | - | "name": "timestamp", | |
| 255 | - | "type": "integer", | |
| 256 | - | "primaryKey": false, | |
| 257 | - | "notNull": true, | |
| 258 | - | "autoincrement": false | |
| 259 | - | }, | |
| 260 | - | "nickname": { | |
| 261 | - | "name": "nickname", | |
| 262 | - | "type": "text", | |
| 263 | - | "primaryKey": false, | |
| 264 | - | "notNull": true, | |
| 265 | - | "autoincrement": false | |
| 266 | - | }, | |
| 267 | - | "name": { | |
| 268 | - | "name": "name", | |
| 269 | - | "type": "text", | |
| 270 | - | "primaryKey": false, | |
| 271 | - | "notNull": false, | |
| 272 | - | "autoincrement": false | |
| 273 | - | } | |
| 274 | - | }, | |
| 275 | - | "name": "message_view", | |
| 276 | - | "isExisting": false, | |
| 277 | - | "definition": "select \"messages\".\"id\", \"messages\".\"content\", \"messages\".\"type\", \"messages\".\"timestamp\", \"users\".\"nickname\", \"chat_rooms\".\"name\" from \"messages\" left join \"users\" on \"messages\".\"sender_id\" = \"users\".\"id\" left join \"chat_rooms\" on \"messages\".\"chat_room_id\" = \"chat_rooms\".\"id\"" | |
| 278 | - | }, | |
| 279 | - | "user_view": { | |
| 280 | - | "columns": { | |
| 281 | - | "id": { | |
| 282 | - | "name": "id", | |
| 283 | - | "type": "text", | |
| 284 | - | "primaryKey": true, | |
| 285 | - | "notNull": true, | |
| 286 | - | "autoincrement": false | |
| 287 | - | }, | |
| 288 | - | "nickname": { | |
| 289 | - | "name": "nickname", | |
| 290 | - | "type": "text", | |
| 291 | - | "primaryKey": false, | |
| 292 | - | "notNull": true, | |
| 293 | - | "autoincrement": false | |
| 294 | - | }, | |
| 295 | - | "status": { | |
| 296 | - | "name": "status", | |
| 297 | - | "type": "text", | |
| 298 | - | "primaryKey": false, | |
| 299 | - | "notNull": false, | |
| 300 | - | "autoincrement": false, | |
| 301 | - | "default": "'offline'" | |
| 302 | - | }, | |
| 303 | - | "avatar_url": { | |
| 304 | - | "name": "avatar_url", | |
| 305 | - | "type": "text", | |
| 306 | - | "primaryKey": false, | |
| 307 | - | "notNull": false, | |
| 308 | - | "autoincrement": false | |
| 309 | - | }, | |
| 310 | - | "last_seen": { | |
| 311 | - | "name": "last_seen", | |
| 312 | - | "type": "integer", | |
| 313 | - | "primaryKey": false, | |
| 314 | - | "notNull": false, | |
| 315 | - | "autoincrement": false | |
| 316 | - | } | |
| 317 | - | }, | |
| 318 | - | "name": "user_view", | |
| 319 | - | "isExisting": false, | |
| 320 | - | "definition": "select \"id\", \"nickname\", \"status\", \"avatar_url\", \"last_seen\" from \"users\"" | |
| 321 | - | } | |
| 322 | - | }, | |
| 323 | - | "enums": {}, | |
| 324 | - | "_meta": { | |
| 325 | - | "schemas": {}, | |
| 326 | - | "tables": {}, | |
| 327 | - | "columns": {} | |
| 328 | - | }, | |
| 329 | - | "internal": { | |
| 330 | - | "indexes": {} | |
| 331 | - | } | |
| 332 | - | } | |
| @@ -1,332 +0,0 @@ | |||||
| 1 | - | { | |||
| 2 | - | "version": "6", | |||
| 3 | - | "dialect": "sqlite", | |||
| 4 | - | "id": "16b13426-2b9d-4084-8e17-71f9de0f72d0", | |||
| 5 | - | "prevId": "00000000-0000-0000-0000-000000000000", | |||
| 6 | - | "tables": { | |||
| 7 | - | "chat_rooms": { | |||
| 8 | - | "name": "chat_rooms", | |||
| 9 | - | "columns": { | |||
| 10 | - | "id": { | |||
| 11 | - | "name": "id", | |||
| 12 | - | "type": "text", | |||
| 13 | - | "primaryKey": true, | |||
| 14 | - | "notNull": true, | |||
| 15 | - | "autoincrement": false | |||
| 16 | - | }, | |||
| 17 | - | "name": { | |||
| 18 | - | "name": "name", | |||
| 19 | - | "type": "text", | |||
| 20 | - | "primaryKey": false, | |||
| 21 | - | "notNull": false, | |||
| 22 | - | "autoincrement": false | |||
| 23 | - | }, | |||
| 24 | - | "type": { | |||
| 25 | - | "name": "type", | |||
| 26 | - | "type": "text", | |||
| 27 | - | "primaryKey": false, | |||
| 28 | - | "notNull": true, | |||
| 29 | - | "autoincrement": false, | |||
| 30 | - | "default": "'direct'" | |||
| 31 | - | }, | |||
| 32 | - | "created_at": { | |||
| 33 | - | "name": "created_at", | |||
| 34 | - | "type": "integer", | |||
| 35 | - | "primaryKey": false, | |||
| 36 | - | "notNull": true, | |||
| 37 | - | "autoincrement": false | |||
| 38 | - | } | |||
| 39 | - | }, | |||
| 40 | - | "indexes": {}, | |||
| 41 | - | "foreignKeys": {}, | |||
| 42 | - | "compositePrimaryKeys": {}, | |||
| 43 | - | "uniqueConstraints": {}, | |||
| 44 | - | "checkConstraints": {} | |||
| 45 | - | }, | |||
| 46 | - | "messages": { | |||
| 47 | - | "name": "messages", | |||
| 48 | - | "columns": { | |||
| 49 | - | "id": { | |||
| 50 | - | "name": "id", | |||
| 51 | - | "type": "text", | |||
| 52 | - | "primaryKey": true, | |||
| 53 | - | "notNull": true, | |||
| 54 | - | "autoincrement": false | |||
| 55 | - | }, | |||
| 56 | - | "chat_room_id": { | |||
| 57 | - | "name": "chat_room_id", | |||
| 58 | - | "type": "text", | |||
| 59 | - | "primaryKey": false, | |||
| 60 | - | "notNull": true, | |||
| 61 | - | "autoincrement": false | |||
| 62 | - | }, | |||
| 63 | - | "sender_id": { | |||
| 64 | - | "name": "sender_id", | |||
| 65 | - | "type": "text", | |||
| 66 | - | "primaryKey": false, | |||
| 67 | - | "notNull": true, | |||
| 68 | - | "autoincrement": false | |||
| 69 | - | }, | |||
| 70 | - | "content": { | |||
| 71 | - | "name": "content", | |||
| 72 | - | "type": "text", | |||
| 73 | - | "primaryKey": false, | |||
| 74 | - | "notNull": true, | |||
| 75 | - | "autoincrement": false | |||
| 76 | - | }, | |||
| 77 | - | "type": { | |||
| 78 | - | "name": "type", | |||
| 79 | - | "type": "text", | |||
| 80 | - | "primaryKey": false, | |||
| 81 | - | "notNull": true, | |||
| 82 | - | "autoincrement": false, | |||
| 83 | - | "default": "'chat'" | |||
| 84 | - | }, | |||
| 85 | - | "timestamp": { | |||
| 86 | - | "name": "timestamp", | |||
| 87 | - | "type": "integer", | |||
| 88 | - | "primaryKey": false, | |||
| 89 | - | "notNull": true, | |||
| 90 | - | "autoincrement": false | |||
| 91 | - | } | |||
| 92 | - | }, | |||
| 93 | - | "indexes": {}, | |||
| 94 | - | "foreignKeys": { | |||
| 95 | - | "messages_chat_room_id_chat_rooms_id_fk": { | |||
| 96 | - | "name": "messages_chat_room_id_chat_rooms_id_fk", | |||
| 97 | - | "tableFrom": "messages", | |||
| 98 | - | "tableTo": "chat_rooms", | |||
| 99 | - | "columnsFrom": ["chat_room_id"], | |||
| 100 | - | "columnsTo": ["id"], | |||
| 101 | - | "onDelete": "no action", | |||
| 102 | - | "onUpdate": "no action" | |||
| 103 | - | }, | |||
| 104 | - | "messages_sender_id_users_id_fk": { | |||
| 105 | - | "name": "messages_sender_id_users_id_fk", | |||
| 106 | - | "tableFrom": "messages", | |||
| 107 | - | "tableTo": "users", | |||
| 108 | - | "columnsFrom": ["sender_id"], | |||
| 109 | - | "columnsTo": ["id"], | |||
| 110 | - | "onDelete": "no action", | |||
| 111 | - | "onUpdate": "no action" | |||
| 112 | - | } | |||
| 113 | - | }, | |||
| 114 | - | "compositePrimaryKeys": {}, | |||
| 115 | - | "uniqueConstraints": {}, | |||
| 116 | - | "checkConstraints": {} | |||
| 117 | - | }, | |||
| 118 | - | "users": { | |||
| 119 | - | "name": "users", | |||
| 120 | - | "columns": { | |||
| 121 | - | "id": { | |||
| 122 | - | "name": "id", | |||
| 123 | - | "type": "text", | |||
| 124 | - | "primaryKey": true, | |||
| 125 | - | "notNull": true, | |||
| 126 | - | "autoincrement": false | |||
| 127 | - | }, | |||
| 128 | - | "email": { | |||
| 129 | - | "name": "email", | |||
| 130 | - | "type": "text", | |||
| 131 | - | "primaryKey": false, | |||
| 132 | - | "notNull": true, | |||
| 133 | - | "autoincrement": false | |||
| 134 | - | }, | |||
| 135 | - | "password": { | |||
| 136 | - | "name": "password", | |||
| 137 | - | "type": "text", | |||
| 138 | - | "primaryKey": false, | |||
| 139 | - | "notNull": true, | |||
| 140 | - | "autoincrement": false | |||
| 141 | - | }, | |||
| 142 | - | "nickname": { | |||
| 143 | - | "name": "nickname", | |||
| 144 | - | "type": "text", | |||
| 145 | - | "primaryKey": false, | |||
| 146 | - | "notNull": true, | |||
| 147 | - | "autoincrement": false | |||
| 148 | - | }, | |||
| 149 | - | "status": { | |||
| 150 | - | "name": "status", | |||
| 151 | - | "type": "text", | |||
| 152 | - | "primaryKey": false, | |||
| 153 | - | "notNull": false, | |||
| 154 | - | "autoincrement": false, | |||
| 155 | - | "default": "'offline'" | |||
| 156 | - | }, | |||
| 157 | - | "avatar_url": { | |||
| 158 | - | "name": "avatar_url", | |||
| 159 | - | "type": "text", | |||
| 160 | - | "primaryKey": false, | |||
| 161 | - | "notNull": false, | |||
| 162 | - | "autoincrement": false | |||
| 163 | - | }, | |||
| 164 | - | "created_at": { | |||
| 165 | - | "name": "created_at", | |||
| 166 | - | "type": "integer", | |||
| 167 | - | "primaryKey": false, | |||
| 168 | - | "notNull": true, | |||
| 169 | - | "autoincrement": false | |||
| 170 | - | }, | |||
| 171 | - | "last_seen": { | |||
| 172 | - | "name": "last_seen", | |||
| 173 | - | "type": "integer", | |||
| 174 | - | "primaryKey": false, | |||
| 175 | - | "notNull": false, | |||
| 176 | - | "autoincrement": false | |||
| 177 | - | } | |||
| 178 | - | }, | |||
| 179 | - | "indexes": { | |||
| 180 | - | "users_email_unique": { | |||
| 181 | - | "name": "users_email_unique", | |||
| 182 | - | "columns": ["email"], | |||
| 183 | - | "isUnique": true | |||
| 184 | - | } | |||
| 185 | - | }, | |||
| 186 | - | "foreignKeys": {}, | |||
| 187 | - | "compositePrimaryKeys": {}, | |||
| 188 | - | "uniqueConstraints": {}, | |||
| 189 | - | "checkConstraints": {} | |||
| 190 | - | } | |||
| 191 | - | }, | |||
| 192 | - | "views": { | |||
| 193 | - | "chat_room_view": { | |||
| 194 | - | "columns": { | |||
| 195 | - | "id": { | |||
| 196 | - | "name": "id", | |||
| 197 | - | "type": "text", | |||
| 198 | - | "primaryKey": true, | |||
| 199 | - | "notNull": true, | |||
| 200 | - | "autoincrement": false | |||
| 201 | - | }, | |||
| 202 | - | "name": { | |||
| 203 | - | "name": "name", | |||
| 204 | - | "type": "text", | |||
| 205 | - | "primaryKey": false, | |||
| 206 | - | "notNull": false, | |||
| 207 | - | "autoincrement": false | |||
| 208 | - | }, | |||
| 209 | - | "type": { | |||
| 210 | - | "name": "type", | |||
| 211 | - | "type": "text", | |||
| 212 | - | "primaryKey": false, | |||
| 213 | - | "notNull": true, | |||
| 214 | - | "autoincrement": false, | |||
| 215 | - | "default": "'direct'" | |||
| 216 | - | }, | |||
| 217 | - | "created_at": { | |||
| 218 | - | "name": "created_at", | |||
| 219 | - | "type": "integer", | |||
| 220 | - | "primaryKey": false, | |||
| 221 | - | "notNull": true, | |||
| 222 | - | "autoincrement": false | |||
| 223 | - | } | |||
| 224 | - | }, | |||
| 225 | - | "name": "chat_room_view", | |||
| 226 | - | "isExisting": false, | |||
| 227 | - | "definition": "select \"id\", \"name\", \"type\", \"created_at\" from \"chat_rooms\"" | |||
| 228 | - | }, | |||
| 229 | - | "message_view": { | |||
| 230 | - | "columns": { | |||
| 231 | - | "id": { | |||
| 232 | - | "name": "id", | |||
| 233 | - | "type": "text", | |||
| 234 | - | "primaryKey": true, | |||
| 235 | - | "notNull": true, | |||
| 236 | - | "autoincrement": false | |||
| 237 | - | }, | |||
| 238 | - | "content": { | |||
| 239 | - | "name": "content", | |||
| 240 | - | "type": "text", | |||
| 241 | - | "primaryKey": false, | |||
| 242 | - | "notNull": true, | |||
| 243 | - | "autoincrement": false | |||
| 244 | - | }, | |||
| 245 | - | "type": { | |||
| 246 | - | "name": "type", | |||
| 247 | - | "type": "text", | |||
| 248 | - | "primaryKey": false, | |||
| 249 | - | "notNull": true, | |||
| 250 | - | "autoincrement": false, | |||
| 251 | - | "default": "'chat'" | |||
| 252 | - | }, | |||
| 253 | - | "timestamp": { | |||
| 254 | - | "name": "timestamp", | |||
| 255 | - | "type": "integer", | |||
| 256 | - | "primaryKey": false, | |||
| 257 | - | "notNull": true, | |||
| 258 | - | "autoincrement": false | |||
| 259 | - | }, | |||
| 260 | - | "nickname": { | |||
| 261 | - | "name": "nickname", | |||
| 262 | - | "type": "text", | |||
| 263 | - | "primaryKey": false, | |||
| 264 | - | "notNull": true, | |||
| 265 | - | "autoincrement": false | |||
| 266 | - | }, | |||
| 267 | - | "name": { | |||
| 268 | - | "name": "name", | |||
| 269 | - | "type": "text", | |||
| 270 | - | "primaryKey": false, | |||
| 271 | - | "notNull": false, | |||
| 272 | - | "autoincrement": false | |||
| 273 | - | } | |||
| 274 | - | }, | |||
| 275 | - | "name": "message_view", | |||
| 276 | - | "isExisting": false, | |||
| 277 | - | "definition": "select \"messages\".\"id\", \"messages\".\"content\", \"messages\".\"type\", \"messages\".\"timestamp\", \"users\".\"nickname\", \"chat_rooms\".\"name\" from \"messages\" left join \"users\" on \"messages\".\"sender_id\" = \"users\".\"id\" left join \"chat_rooms\" on \"messages\".\"chat_room_id\" = \"chat_rooms\".\"id\"" | |||
| 278 | - | }, | |||
| 279 | - | "user_view": { | |||
| 280 | - | "columns": { | |||
| 281 | - | "id": { | |||
| 282 | - | "name": "id", | |||
| 283 | - | "type": "text", | |||
| 284 | - | "primaryKey": true, | |||
| 285 | - | "notNull": true, | |||
| 286 | - | "autoincrement": false | |||
| 287 | - | }, | |||
| 288 | - | "nickname": { | |||
| 289 | - | "name": "nickname", | |||
| 290 | - | "type": "text", | |||
| 291 | - | "primaryKey": false, | |||
| 292 | - | "notNull": true, | |||
| 293 | - | "autoincrement": false | |||
| 294 | - | }, | |||
| 295 | - | "status": { | |||
| 296 | - | "name": "status", | |||
| 297 | - | "type": "text", | |||
| 298 | - | "primaryKey": false, | |||
| 299 | - | "notNull": false, | |||
| 300 | - | "autoincrement": false, | |||
| 301 | - | "default": "'offline'" | |||
| 302 | - | }, | |||
| 303 | - | "avatar_url": { | |||
| 304 | - | "name": "avatar_url", | |||
| 305 | - | "type": "text", | |||
| 306 | - | "primaryKey": false, | |||
| 307 | - | "notNull": false, | |||
| 308 | - | "autoincrement": false | |||
| 309 | - | }, | |||
| 310 | - | "last_seen": { | |||
| 311 | - | "name": "last_seen", | |||
| 312 | - | "type": "integer", | |||
| 313 | - | "primaryKey": false, | |||
| 314 | - | "notNull": false, | |||
| 315 | - | "autoincrement": false | |||
| 316 | - | } | |||
| 317 | - | }, | |||
| 318 | - | "name": "user_view", | |||
| 319 | - | "isExisting": false, | |||
| 320 | - | "definition": "select \"id\", \"nickname\", \"status\", \"avatar_url\", \"last_seen\" from \"users\"" | |||
| 321 | - | } | |||
| 322 | - | }, | |||
| 323 | - | "enums": {}, | |||
| 324 | - | "_meta": { | |||
| 325 | - | "schemas": {}, | |||
| 326 | - | "tables": {}, | |||
| 327 | - | "columns": {} | |||
| 328 | - | }, | |||
| 329 | - | "internal": { | |||
| 330 | - | "indexes": {} | |||
| 331 | - | } | |||
| 332 | - | } | |||
D drizzle/meta/0001_snapshot.json +0 -367
| @@ -1,367 +0,0 @@ | |||
| 1 | - | { | |
| 2 | - | "version": "6", | |
| 3 | - | "dialect": "sqlite", | |
| 4 | - | "id": "9090026e-dae4-4b69-8539-471ebf6ec7e6", | |
| 5 | - | "prevId": "16b13426-2b9d-4084-8e17-71f9de0f72d0", | |
| 6 | - | "tables": { | |
| 7 | - | "chat_rooms": { | |
| 8 | - | "name": "chat_rooms", | |
| 9 | - | "columns": { | |
| 10 | - | "id": { | |
| 11 | - | "name": "id", | |
| 12 | - | "type": "text", | |
| 13 | - | "primaryKey": true, | |
| 14 | - | "notNull": true, | |
| 15 | - | "autoincrement": false | |
| 16 | - | }, | |
| 17 | - | "name": { | |
| 18 | - | "name": "name", | |
| 19 | - | "type": "text", | |
| 20 | - | "primaryKey": false, | |
| 21 | - | "notNull": false, | |
| 22 | - | "autoincrement": false | |
| 23 | - | }, | |
| 24 | - | "type": { | |
| 25 | - | "name": "type", | |
| 26 | - | "type": "text", | |
| 27 | - | "primaryKey": false, | |
| 28 | - | "notNull": true, | |
| 29 | - | "autoincrement": false, | |
| 30 | - | "default": "'direct'" | |
| 31 | - | }, | |
| 32 | - | "created_at": { | |
| 33 | - | "name": "created_at", | |
| 34 | - | "type": "integer", | |
| 35 | - | "primaryKey": false, | |
| 36 | - | "notNull": true, | |
| 37 | - | "autoincrement": false | |
| 38 | - | } | |
| 39 | - | }, | |
| 40 | - | "indexes": {}, | |
| 41 | - | "foreignKeys": {}, | |
| 42 | - | "compositePrimaryKeys": {}, | |
| 43 | - | "uniqueConstraints": {}, | |
| 44 | - | "checkConstraints": {} | |
| 45 | - | }, | |
| 46 | - | "messages": { | |
| 47 | - | "name": "messages", | |
| 48 | - | "columns": { | |
| 49 | - | "id": { | |
| 50 | - | "name": "id", | |
| 51 | - | "type": "text", | |
| 52 | - | "primaryKey": true, | |
| 53 | - | "notNull": true, | |
| 54 | - | "autoincrement": false | |
| 55 | - | }, | |
| 56 | - | "chat_room_id": { | |
| 57 | - | "name": "chat_room_id", | |
| 58 | - | "type": "text", | |
| 59 | - | "primaryKey": false, | |
| 60 | - | "notNull": true, | |
| 61 | - | "autoincrement": false | |
| 62 | - | }, | |
| 63 | - | "sender_id": { | |
| 64 | - | "name": "sender_id", | |
| 65 | - | "type": "text", | |
| 66 | - | "primaryKey": false, | |
| 67 | - | "notNull": true, | |
| 68 | - | "autoincrement": false | |
| 69 | - | }, | |
| 70 | - | "content": { | |
| 71 | - | "name": "content", | |
| 72 | - | "type": "text", | |
| 73 | - | "primaryKey": false, | |
| 74 | - | "notNull": true, | |
| 75 | - | "autoincrement": false | |
| 76 | - | }, | |
| 77 | - | "type": { | |
| 78 | - | "name": "type", | |
| 79 | - | "type": "text", | |
| 80 | - | "primaryKey": false, | |
| 81 | - | "notNull": true, | |
| 82 | - | "autoincrement": false, | |
| 83 | - | "default": "'chat'" | |
| 84 | - | }, | |
| 85 | - | "timestamp": { | |
| 86 | - | "name": "timestamp", | |
| 87 | - | "type": "integer", | |
| 88 | - | "primaryKey": false, | |
| 89 | - | "notNull": true, | |
| 90 | - | "autoincrement": false | |
| 91 | - | } | |
| 92 | - | }, | |
| 93 | - | "indexes": {}, | |
| 94 | - | "foreignKeys": { | |
| 95 | - | "messages_chat_room_id_chat_rooms_id_fk": { | |
| 96 | - | "name": "messages_chat_room_id_chat_rooms_id_fk", | |
| 97 | - | "tableFrom": "messages", | |
| 98 | - | "tableTo": "chat_rooms", | |
| 99 | - | "columnsFrom": ["chat_room_id"], | |
| 100 | - | "columnsTo": ["id"], | |
| 101 | - | "onDelete": "no action", | |
| 102 | - | "onUpdate": "no action" | |
| 103 | - | }, | |
| 104 | - | "messages_sender_id_users_id_fk": { | |
| 105 | - | "name": "messages_sender_id_users_id_fk", | |
| 106 | - | "tableFrom": "messages", | |
| 107 | - | "tableTo": "users", | |
| 108 | - | "columnsFrom": ["sender_id"], | |
| 109 | - | "columnsTo": ["id"], | |
| 110 | - | "onDelete": "no action", | |
| 111 | - | "onUpdate": "no action" | |
| 112 | - | } | |
| 113 | - | }, | |
| 114 | - | "compositePrimaryKeys": {}, | |
| 115 | - | "uniqueConstraints": {}, | |
| 116 | - | "checkConstraints": {} | |
| 117 | - | }, | |
| 118 | - | "sessions": { | |
| 119 | - | "name": "sessions", | |
| 120 | - | "columns": { | |
| 121 | - | "id": { | |
| 122 | - | "name": "id", | |
| 123 | - | "type": "text", | |
| 124 | - | "primaryKey": true, | |
| 125 | - | "notNull": true, | |
| 126 | - | "autoincrement": false | |
| 127 | - | }, | |
| 128 | - | "user_id": { | |
| 129 | - | "name": "user_id", | |
| 130 | - | "type": "text", | |
| 131 | - | "primaryKey": false, | |
| 132 | - | "notNull": true, | |
| 133 | - | "autoincrement": false | |
| 134 | - | }, | |
| 135 | - | "expires_at": { | |
| 136 | - | "name": "expires_at", | |
| 137 | - | "type": "integer", | |
| 138 | - | "primaryKey": false, | |
| 139 | - | "notNull": true, | |
| 140 | - | "autoincrement": false | |
| 141 | - | }, | |
| 142 | - | "created_at": { | |
| 143 | - | "name": "created_at", | |
| 144 | - | "type": "integer", | |
| 145 | - | "primaryKey": false, | |
| 146 | - | "notNull": true, | |
| 147 | - | "autoincrement": false | |
| 148 | - | } | |
| 149 | - | }, | |
| 150 | - | "indexes": {}, | |
| 151 | - | "foreignKeys": { | |
| 152 | - | "sessions_user_id_users_id_fk": { | |
| 153 | - | "name": "sessions_user_id_users_id_fk", | |
| 154 | - | "tableFrom": "sessions", | |
| 155 | - | "tableTo": "users", | |
| 156 | - | "columnsFrom": ["user_id"], | |
| 157 | - | "columnsTo": ["id"], | |
| 158 | - | "onDelete": "no action", | |
| 159 | - | "onUpdate": "no action" | |
| 160 | - | } | |
| 161 | - | }, | |
| 162 | - | "compositePrimaryKeys": {}, | |
| 163 | - | "uniqueConstraints": {}, | |
| 164 | - | "checkConstraints": {} | |
| 165 | - | }, | |
| 166 | - | "users": { | |
| 167 | - | "name": "users", | |
| 168 | - | "columns": { | |
| 169 | - | "id": { | |
| 170 | - | "name": "id", | |
| 171 | - | "type": "text", | |
| 172 | - | "primaryKey": true, | |
| 173 | - | "notNull": true, | |
| 174 | - | "autoincrement": false | |
| 175 | - | }, | |
| 176 | - | "password": { | |
| 177 | - | "name": "password", | |
| 178 | - | "type": "text", | |
| 179 | - | "primaryKey": false, | |
| 180 | - | "notNull": true, | |
| 181 | - | "autoincrement": false | |
| 182 | - | }, | |
| 183 | - | "nickname": { | |
| 184 | - | "name": "nickname", | |
| 185 | - | "type": "text", | |
| 186 | - | "primaryKey": false, | |
| 187 | - | "notNull": true, | |
| 188 | - | "autoincrement": false | |
| 189 | - | }, | |
| 190 | - | "status": { | |
| 191 | - | "name": "status", | |
| 192 | - | "type": "text", | |
| 193 | - | "primaryKey": false, | |
| 194 | - | "notNull": true, | |
| 195 | - | "autoincrement": false, | |
| 196 | - | "default": "'offline'" | |
| 197 | - | }, | |
| 198 | - | "avatar_url": { | |
| 199 | - | "name": "avatar_url", | |
| 200 | - | "type": "text", | |
| 201 | - | "primaryKey": false, | |
| 202 | - | "notNull": false, | |
| 203 | - | "autoincrement": false | |
| 204 | - | }, | |
| 205 | - | "created_at": { | |
| 206 | - | "name": "created_at", | |
| 207 | - | "type": "integer", | |
| 208 | - | "primaryKey": false, | |
| 209 | - | "notNull": true, | |
| 210 | - | "autoincrement": false | |
| 211 | - | }, | |
| 212 | - | "last_seen": { | |
| 213 | - | "name": "last_seen", | |
| 214 | - | "type": "integer", | |
| 215 | - | "primaryKey": false, | |
| 216 | - | "notNull": false, | |
| 217 | - | "autoincrement": false | |
| 218 | - | } | |
| 219 | - | }, | |
| 220 | - | "indexes": {}, | |
| 221 | - | "foreignKeys": {}, | |
| 222 | - | "compositePrimaryKeys": {}, | |
| 223 | - | "uniqueConstraints": {}, | |
| 224 | - | "checkConstraints": {} | |
| 225 | - | } | |
| 226 | - | }, | |
| 227 | - | "views": { | |
| 228 | - | "chat_room_view": { | |
| 229 | - | "columns": { | |
| 230 | - | "id": { | |
| 231 | - | "name": "id", | |
| 232 | - | "type": "text", | |
| 233 | - | "primaryKey": true, | |
| 234 | - | "notNull": true, | |
| 235 | - | "autoincrement": false | |
| 236 | - | }, | |
| 237 | - | "name": { | |
| 238 | - | "name": "name", | |
| 239 | - | "type": "text", | |
| 240 | - | "primaryKey": false, | |
| 241 | - | "notNull": false, | |
| 242 | - | "autoincrement": false | |
| 243 | - | }, | |
| 244 | - | "type": { | |
| 245 | - | "name": "type", | |
| 246 | - | "type": "text", | |
| 247 | - | "primaryKey": false, | |
| 248 | - | "notNull": true, | |
| 249 | - | "autoincrement": false, | |
| 250 | - | "default": "'direct'" | |
| 251 | - | }, | |
| 252 | - | "created_at": { | |
| 253 | - | "name": "created_at", | |
| 254 | - | "type": "integer", | |
| 255 | - | "primaryKey": false, | |
| 256 | - | "notNull": true, | |
| 257 | - | "autoincrement": false | |
| 258 | - | } | |
| 259 | - | }, | |
| 260 | - | "name": "chat_room_view", | |
| 261 | - | "isExisting": false, | |
| 262 | - | "definition": "select \"id\", \"name\", \"type\", \"created_at\" from \"chat_rooms\"" | |
| 263 | - | }, | |
| 264 | - | "message_view": { | |
| 265 | - | "columns": { | |
| 266 | - | "id": { | |
| 267 | - | "name": "id", | |
| 268 | - | "type": "text", | |
| 269 | - | "primaryKey": true, | |
| 270 | - | "notNull": true, | |
| 271 | - | "autoincrement": false | |
| 272 | - | }, | |
| 273 | - | "content": { | |
| 274 | - | "name": "content", | |
| 275 | - | "type": "text", | |
| 276 | - | "primaryKey": false, | |
| 277 | - | "notNull": true, | |
| 278 | - | "autoincrement": false | |
| 279 | - | }, | |
| 280 | - | "type": { | |
| 281 | - | "name": "type", | |
| 282 | - | "type": "text", | |
| 283 | - | "primaryKey": false, | |
| 284 | - | "notNull": true, | |
| 285 | - | "autoincrement": false, | |
| 286 | - | "default": "'chat'" | |
| 287 | - | }, | |
| 288 | - | "timestamp": { | |
| 289 | - | "name": "timestamp", | |
| 290 | - | "type": "integer", | |
| 291 | - | "primaryKey": false, | |
| 292 | - | "notNull": true, | |
| 293 | - | "autoincrement": false | |
| 294 | - | }, | |
| 295 | - | "nickname": { | |
| 296 | - | "name": "nickname", | |
| 297 | - | "type": "text", | |
| 298 | - | "primaryKey": false, | |
| 299 | - | "notNull": true, | |
| 300 | - | "autoincrement": false | |
| 301 | - | }, | |
| 302 | - | "name": { | |
| 303 | - | "name": "name", | |
| 304 | - | "type": "text", | |
| 305 | - | "primaryKey": false, | |
| 306 | - | "notNull": false, | |
| 307 | - | "autoincrement": false | |
| 308 | - | } | |
| 309 | - | }, | |
| 310 | - | "name": "message_view", | |
| 311 | - | "isExisting": false, | |
| 312 | - | "definition": "select \"messages\".\"id\", \"messages\".\"content\", \"messages\".\"type\", \"messages\".\"timestamp\", \"users\".\"nickname\", \"chat_rooms\".\"name\" from \"messages\" left join \"users\" on \"messages\".\"sender_id\" = \"users\".\"id\" left join \"chat_rooms\" on \"messages\".\"chat_room_id\" = \"chat_rooms\".\"id\"" | |
| 313 | - | }, | |
| 314 | - | "user_view": { | |
| 315 | - | "columns": { | |
| 316 | - | "id": { | |
| 317 | - | "name": "id", | |
| 318 | - | "type": "text", | |
| 319 | - | "primaryKey": true, | |
| 320 | - | "notNull": true, | |
| 321 | - | "autoincrement": false | |
| 322 | - | }, | |
| 323 | - | "nickname": { | |
| 324 | - | "name": "nickname", | |
| 325 | - | "type": "text", | |
| 326 | - | "primaryKey": false, | |
| 327 | - | "notNull": true, | |
| 328 | - | "autoincrement": false | |
| 329 | - | }, | |
| 330 | - | "status": { | |
| 331 | - | "name": "status", | |
| 332 | - | "type": "text", | |
| 333 | - | "primaryKey": false, | |
| 334 | - | "notNull": true, | |
| 335 | - | "autoincrement": false, | |
| 336 | - | "default": "'offline'" | |
| 337 | - | }, | |
| 338 | - | "avatar_url": { | |
| 339 | - | "name": "avatar_url", | |
| 340 | - | "type": "text", | |
| 341 | - | "primaryKey": false, | |
| 342 | - | "notNull": false, | |
| 343 | - | "autoincrement": false | |
| 344 | - | }, | |
| 345 | - | "last_seen": { | |
| 346 | - | "name": "last_seen", | |
| 347 | - | "type": "integer", | |
| 348 | - | "primaryKey": false, | |
| 349 | - | "notNull": false, | |
| 350 | - | "autoincrement": false | |
| 351 | - | } | |
| 352 | - | }, | |
| 353 | - | "name": "user_view", | |
| 354 | - | "isExisting": false, | |
| 355 | - | "definition": "select \"id\", \"nickname\", \"status\", \"avatar_url\", \"last_seen\" from \"users\"" | |
| 356 | - | } | |
| 357 | - | }, | |
| 358 | - | "enums": {}, | |
| 359 | - | "_meta": { | |
| 360 | - | "schemas": {}, | |
| 361 | - | "tables": {}, | |
| 362 | - | "columns": {} | |
| 363 | - | }, | |
| 364 | - | "internal": { | |
| 365 | - | "indexes": {} | |
| 366 | - | } | |
| 367 | - | } | |
| @@ -1,367 +0,0 @@ | |||||
| 1 | - | { | |||
| 2 | - | "version": "6", | |||
| 3 | - | "dialect": "sqlite", | |||
| 4 | - | "id": "9090026e-dae4-4b69-8539-471ebf6ec7e6", | |||
| 5 | - | "prevId": "16b13426-2b9d-4084-8e17-71f9de0f72d0", | |||
| 6 | - | "tables": { | |||
| 7 | - | "chat_rooms": { | |||
| 8 | - | "name": "chat_rooms", | |||
| 9 | - | "columns": { | |||
| 10 | - | "id": { | |||
| 11 | - | "name": "id", | |||
| 12 | - | "type": "text", | |||
| 13 | - | "primaryKey": true, | |||
| 14 | - | "notNull": true, | |||
| 15 | - | "autoincrement": false | |||
| 16 | - | }, | |||
| 17 | - | "name": { | |||
| 18 | - | "name": "name", | |||
| 19 | - | "type": "text", | |||
| 20 | - | "primaryKey": false, | |||
| 21 | - | "notNull": false, | |||
| 22 | - | "autoincrement": false | |||
| 23 | - | }, | |||
| 24 | - | "type": { | |||
| 25 | - | "name": "type", | |||
| 26 | - | "type": "text", | |||
| 27 | - | "primaryKey": false, | |||
| 28 | - | "notNull": true, | |||
| 29 | - | "autoincrement": false, | |||
| 30 | - | "default": "'direct'" | |||
| 31 | - | }, | |||
| 32 | - | "created_at": { | |||
| 33 | - | "name": "created_at", | |||
| 34 | - | "type": "integer", | |||
| 35 | - | "primaryKey": false, | |||
| 36 | - | "notNull": true, | |||
| 37 | - | "autoincrement": false | |||
| 38 | - | } | |||
| 39 | - | }, | |||
| 40 | - | "indexes": {}, | |||
| 41 | - | "foreignKeys": {}, | |||
| 42 | - | "compositePrimaryKeys": {}, | |||
| 43 | - | "uniqueConstraints": {}, | |||
| 44 | - | "checkConstraints": {} | |||
| 45 | - | }, | |||
| 46 | - | "messages": { | |||
| 47 | - | "name": "messages", | |||
| 48 | - | "columns": { | |||
| 49 | - | "id": { | |||
| 50 | - | "name": "id", | |||
| 51 | - | "type": "text", | |||
| 52 | - | "primaryKey": true, | |||
| 53 | - | "notNull": true, | |||
| 54 | - | "autoincrement": false | |||
| 55 | - | }, | |||
| 56 | - | "chat_room_id": { | |||
| 57 | - | "name": "chat_room_id", | |||
| 58 | - | "type": "text", | |||
| 59 | - | "primaryKey": false, | |||
| 60 | - | "notNull": true, | |||
| 61 | - | "autoincrement": false | |||
| 62 | - | }, | |||
| 63 | - | "sender_id": { | |||
| 64 | - | "name": "sender_id", | |||
| 65 | - | "type": "text", | |||
| 66 | - | "primaryKey": false, | |||
| 67 | - | "notNull": true, | |||
| 68 | - | "autoincrement": false | |||
| 69 | - | }, | |||
| 70 | - | "content": { | |||
| 71 | - | "name": "content", | |||
| 72 | - | "type": "text", | |||
| 73 | - | "primaryKey": false, | |||
| 74 | - | "notNull": true, | |||
| 75 | - | "autoincrement": false | |||
| 76 | - | }, | |||
| 77 | - | "type": { | |||
| 78 | - | "name": "type", | |||
| 79 | - | "type": "text", | |||
| 80 | - | "primaryKey": false, | |||
| 81 | - | "notNull": true, | |||
| 82 | - | "autoincrement": false, | |||
| 83 | - | "default": "'chat'" | |||
| 84 | - | }, | |||
| 85 | - | "timestamp": { | |||
| 86 | - | "name": "timestamp", | |||
| 87 | - | "type": "integer", | |||
| 88 | - | "primaryKey": false, | |||
| 89 | - | "notNull": true, | |||
| 90 | - | "autoincrement": false | |||
| 91 | - | } | |||
| 92 | - | }, | |||
| 93 | - | "indexes": {}, | |||
| 94 | - | "foreignKeys": { | |||
| 95 | - | "messages_chat_room_id_chat_rooms_id_fk": { | |||
| 96 | - | "name": "messages_chat_room_id_chat_rooms_id_fk", | |||
| 97 | - | "tableFrom": "messages", | |||
| 98 | - | "tableTo": "chat_rooms", | |||
| 99 | - | "columnsFrom": ["chat_room_id"], | |||
| 100 | - | "columnsTo": ["id"], | |||
| 101 | - | "onDelete": "no action", | |||
| 102 | - | "onUpdate": "no action" | |||
| 103 | - | }, | |||
| 104 | - | "messages_sender_id_users_id_fk": { | |||
| 105 | - | "name": "messages_sender_id_users_id_fk", | |||
| 106 | - | "tableFrom": "messages", | |||
| 107 | - | "tableTo": "users", | |||
| 108 | - | "columnsFrom": ["sender_id"], | |||
| 109 | - | "columnsTo": ["id"], | |||
| 110 | - | "onDelete": "no action", | |||
| 111 | - | "onUpdate": "no action" | |||
| 112 | - | } | |||
| 113 | - | }, | |||
| 114 | - | "compositePrimaryKeys": {}, | |||
| 115 | - | "uniqueConstraints": {}, | |||
| 116 | - | "checkConstraints": {} | |||
| 117 | - | }, | |||
| 118 | - | "sessions": { | |||
| 119 | - | "name": "sessions", | |||
| 120 | - | "columns": { | |||
| 121 | - | "id": { | |||
| 122 | - | "name": "id", | |||
| 123 | - | "type": "text", | |||
| 124 | - | "primaryKey": true, | |||
| 125 | - | "notNull": true, | |||
| 126 | - | "autoincrement": false | |||
| 127 | - | }, | |||
| 128 | - | "user_id": { | |||
| 129 | - | "name": "user_id", | |||
| 130 | - | "type": "text", | |||
| 131 | - | "primaryKey": false, | |||
| 132 | - | "notNull": true, | |||
| 133 | - | "autoincrement": false | |||
| 134 | - | }, | |||
| 135 | - | "expires_at": { | |||
| 136 | - | "name": "expires_at", | |||
| 137 | - | "type": "integer", | |||
| 138 | - | "primaryKey": false, | |||
| 139 | - | "notNull": true, | |||
| 140 | - | "autoincrement": false | |||
| 141 | - | }, | |||
| 142 | - | "created_at": { | |||
| 143 | - | "name": "created_at", | |||
| 144 | - | "type": "integer", | |||
| 145 | - | "primaryKey": false, | |||
| 146 | - | "notNull": true, | |||
| 147 | - | "autoincrement": false | |||
| 148 | - | } | |||
| 149 | - | }, | |||
| 150 | - | "indexes": {}, | |||
| 151 | - | "foreignKeys": { | |||
| 152 | - | "sessions_user_id_users_id_fk": { | |||
| 153 | - | "name": "sessions_user_id_users_id_fk", | |||
| 154 | - | "tableFrom": "sessions", | |||
| 155 | - | "tableTo": "users", | |||
| 156 | - | "columnsFrom": ["user_id"], | |||
| 157 | - | "columnsTo": ["id"], | |||
| 158 | - | "onDelete": "no action", | |||
| 159 | - | "onUpdate": "no action" | |||
| 160 | - | } | |||
| 161 | - | }, | |||
| 162 | - | "compositePrimaryKeys": {}, | |||
| 163 | - | "uniqueConstraints": {}, | |||
| 164 | - | "checkConstraints": {} | |||
| 165 | - | }, | |||
| 166 | - | "users": { | |||
| 167 | - | "name": "users", | |||
| 168 | - | "columns": { | |||
| 169 | - | "id": { | |||
| 170 | - | "name": "id", | |||
| 171 | - | "type": "text", | |||
| 172 | - | "primaryKey": true, | |||
| 173 | - | "notNull": true, | |||
| 174 | - | "autoincrement": false | |||
| 175 | - | }, | |||
| 176 | - | "password": { | |||
| 177 | - | "name": "password", | |||
| 178 | - | "type": "text", | |||
| 179 | - | "primaryKey": false, | |||
| 180 | - | "notNull": true, | |||
| 181 | - | "autoincrement": false | |||
| 182 | - | }, | |||
| 183 | - | "nickname": { | |||
| 184 | - | "name": "nickname", | |||
| 185 | - | "type": "text", | |||
| 186 | - | "primaryKey": false, | |||
| 187 | - | "notNull": true, | |||
| 188 | - | "autoincrement": false | |||
| 189 | - | }, | |||
| 190 | - | "status": { | |||
| 191 | - | "name": "status", | |||
| 192 | - | "type": "text", | |||
| 193 | - | "primaryKey": false, | |||
| 194 | - | "notNull": true, | |||
| 195 | - | "autoincrement": false, | |||
| 196 | - | "default": "'offline'" | |||
| 197 | - | }, | |||
| 198 | - | "avatar_url": { | |||
| 199 | - | "name": "avatar_url", | |||
| 200 | - | "type": "text", | |||
| 201 | - | "primaryKey": false, | |||
| 202 | - | "notNull": false, | |||
| 203 | - | "autoincrement": false | |||
| 204 | - | }, | |||
| 205 | - | "created_at": { | |||
| 206 | - | "name": "created_at", | |||
| 207 | - | "type": "integer", | |||
| 208 | - | "primaryKey": false, | |||
| 209 | - | "notNull": true, | |||
| 210 | - | "autoincrement": false | |||
| 211 | - | }, | |||
| 212 | - | "last_seen": { | |||
| 213 | - | "name": "last_seen", | |||
| 214 | - | "type": "integer", | |||
| 215 | - | "primaryKey": false, | |||
| 216 | - | "notNull": false, | |||
| 217 | - | "autoincrement": false | |||
| 218 | - | } | |||
| 219 | - | }, | |||
| 220 | - | "indexes": {}, | |||
| 221 | - | "foreignKeys": {}, | |||
| 222 | - | "compositePrimaryKeys": {}, | |||
| 223 | - | "uniqueConstraints": {}, | |||
| 224 | - | "checkConstraints": {} | |||
| 225 | - | } | |||
| 226 | - | }, | |||
| 227 | - | "views": { | |||
| 228 | - | "chat_room_view": { | |||
| 229 | - | "columns": { | |||
| 230 | - | "id": { | |||
| 231 | - | "name": "id", | |||
| 232 | - | "type": "text", | |||
| 233 | - | "primaryKey": true, | |||
| 234 | - | "notNull": true, | |||
| 235 | - | "autoincrement": false | |||
| 236 | - | }, | |||
| 237 | - | "name": { | |||
| 238 | - | "name": "name", | |||
| 239 | - | "type": "text", | |||
| 240 | - | "primaryKey": false, | |||
| 241 | - | "notNull": false, | |||
| 242 | - | "autoincrement": false | |||
| 243 | - | }, | |||
| 244 | - | "type": { | |||
| 245 | - | "name": "type", | |||
| 246 | - | "type": "text", | |||
| 247 | - | "primaryKey": false, | |||
| 248 | - | "notNull": true, | |||
| 249 | - | "autoincrement": false, | |||
| 250 | - | "default": "'direct'" | |||
| 251 | - | }, | |||
| 252 | - | "created_at": { | |||
| 253 | - | "name": "created_at", | |||
| 254 | - | "type": "integer", | |||
| 255 | - | "primaryKey": false, | |||
| 256 | - | "notNull": true, | |||
| 257 | - | "autoincrement": false | |||
| 258 | - | } | |||
| 259 | - | }, | |||
| 260 | - | "name": "chat_room_view", | |||
| 261 | - | "isExisting": false, | |||
| 262 | - | "definition": "select \"id\", \"name\", \"type\", \"created_at\" from \"chat_rooms\"" | |||
| 263 | - | }, | |||
| 264 | - | "message_view": { | |||
| 265 | - | "columns": { | |||
| 266 | - | "id": { | |||
| 267 | - | "name": "id", | |||
| 268 | - | "type": "text", | |||
| 269 | - | "primaryKey": true, | |||
| 270 | - | "notNull": true, | |||
| 271 | - | "autoincrement": false | |||
| 272 | - | }, | |||
| 273 | - | "content": { | |||
| 274 | - | "name": "content", | |||
| 275 | - | "type": "text", | |||
| 276 | - | "primaryKey": false, | |||
| 277 | - | "notNull": true, | |||
| 278 | - | "autoincrement": false | |||
| 279 | - | }, | |||
| 280 | - | "type": { | |||
| 281 | - | "name": "type", | |||
| 282 | - | "type": "text", | |||
| 283 | - | "primaryKey": false, | |||
| 284 | - | "notNull": true, | |||
| 285 | - | "autoincrement": false, | |||
| 286 | - | "default": "'chat'" | |||
| 287 | - | }, | |||
| 288 | - | "timestamp": { | |||
| 289 | - | "name": "timestamp", | |||
| 290 | - | "type": "integer", | |||
| 291 | - | "primaryKey": false, | |||
| 292 | - | "notNull": true, | |||
| 293 | - | "autoincrement": false | |||
| 294 | - | }, | |||
| 295 | - | "nickname": { | |||
| 296 | - | "name": "nickname", | |||
| 297 | - | "type": "text", | |||
| 298 | - | "primaryKey": false, | |||
| 299 | - | "notNull": true, | |||
| 300 | - | "autoincrement": false | |||
| 301 | - | }, | |||
| 302 | - | "name": { | |||
| 303 | - | "name": "name", | |||
| 304 | - | "type": "text", | |||
| 305 | - | "primaryKey": false, | |||
| 306 | - | "notNull": false, | |||
| 307 | - | "autoincrement": false | |||
| 308 | - | } | |||
| 309 | - | }, | |||
| 310 | - | "name": "message_view", | |||
| 311 | - | "isExisting": false, | |||
| 312 | - | "definition": "select \"messages\".\"id\", \"messages\".\"content\", \"messages\".\"type\", \"messages\".\"timestamp\", \"users\".\"nickname\", \"chat_rooms\".\"name\" from \"messages\" left join \"users\" on \"messages\".\"sender_id\" = \"users\".\"id\" left join \"chat_rooms\" on \"messages\".\"chat_room_id\" = \"chat_rooms\".\"id\"" | |||
| 313 | - | }, | |||
| 314 | - | "user_view": { | |||
| 315 | - | "columns": { | |||
| 316 | - | "id": { | |||
| 317 | - | "name": "id", | |||
| 318 | - | "type": "text", | |||
| 319 | - | "primaryKey": true, | |||
| 320 | - | "notNull": true, | |||
| 321 | - | "autoincrement": false | |||
| 322 | - | }, | |||
| 323 | - | "nickname": { | |||
| 324 | - | "name": "nickname", | |||
| 325 | - | "type": "text", | |||
| 326 | - | "primaryKey": false, | |||
| 327 | - | "notNull": true, | |||
| 328 | - | "autoincrement": false | |||
| 329 | - | }, | |||
| 330 | - | "status": { | |||
| 331 | - | "name": "status", | |||
| 332 | - | "type": "text", | |||
| 333 | - | "primaryKey": false, | |||
| 334 | - | "notNull": true, | |||
| 335 | - | "autoincrement": false, | |||
| 336 | - | "default": "'offline'" | |||
| 337 | - | }, | |||
| 338 | - | "avatar_url": { | |||
| 339 | - | "name": "avatar_url", | |||
| 340 | - | "type": "text", | |||
| 341 | - | "primaryKey": false, | |||
| 342 | - | "notNull": false, | |||
| 343 | - | "autoincrement": false | |||
| 344 | - | }, | |||
| 345 | - | "last_seen": { | |||
| 346 | - | "name": "last_seen", | |||
| 347 | - | "type": "integer", | |||
| 348 | - | "primaryKey": false, | |||
| 349 | - | "notNull": false, | |||
| 350 | - | "autoincrement": false | |||
| 351 | - | } | |||
| 352 | - | }, | |||
| 353 | - | "name": "user_view", | |||
| 354 | - | "isExisting": false, | |||
| 355 | - | "definition": "select \"id\", \"nickname\", \"status\", \"avatar_url\", \"last_seen\" from \"users\"" | |||
| 356 | - | } | |||
| 357 | - | }, | |||
| 358 | - | "enums": {}, | |||
| 359 | - | "_meta": { | |||
| 360 | - | "schemas": {}, | |||
| 361 | - | "tables": {}, | |||
| 362 | - | "columns": {} | |||
| 363 | - | }, | |||
| 364 | - | "internal": { | |||
| 365 | - | "indexes": {} | |||
| 366 | - | } | |||
| 367 | - | } | |||
D drizzle/meta/_journal.json +0 -20
| @@ -1,20 +0,0 @@ | |||
| 1 | - | { | |
| 2 | - | "version": "7", | |
| 3 | - | "dialect": "sqlite", | |
| 4 | - | "entries": [ | |
| 5 | - | { | |
| 6 | - | "idx": 0, | |
| 7 | - | "version": "6", | |
| 8 | - | "when": 1739208055141, | |
| 9 | - | "tag": "0000_shallow_ghost_rider", | |
| 10 | - | "breakpoints": true | |
| 11 | - | }, | |
| 12 | - | { | |
| 13 | - | "idx": 1, | |
| 14 | - | "version": "6", | |
| 15 | - | "when": 1739432549447, | |
| 16 | - | "tag": "0001_blushing_jean_grey", | |
| 17 | - | "breakpoints": true | |
| 18 | - | } | |
| 19 | - | ] | |
| 20 | - | } | |
| @@ -1,20 +0,0 @@ | |||||
| 1 | - | { | |||
| 2 | - | "version": "7", | |||
| 3 | - | "dialect": "sqlite", | |||
| 4 | - | "entries": [ | |||
| 5 | - | { | |||
| 6 | - | "idx": 0, | |||
| 7 | - | "version": "6", | |||
| 8 | - | "when": 1739208055141, | |||
| 9 | - | "tag": "0000_shallow_ghost_rider", | |||
| 10 | - | "breakpoints": true | |||
| 11 | - | }, | |||
| 12 | - | { | |||
| 13 | - | "idx": 1, | |||
| 14 | - | "version": "6", | |||
| 15 | - | "when": 1739432549447, | |||
| 16 | - | "tag": "0001_blushing_jean_grey", | |||
| 17 | - | "breakpoints": true | |||
| 18 | - | } | |||
| 19 | - | ] | |||
| 20 | - | } | |||
D src/lib/buddyListCache.ts +0 -55
| @@ -1,55 +0,0 @@ | |||
| 1 | - | import { createLogger } from './utils/logger.server'; | |
| 2 | - | import type { SafeUser } from './types/chat'; | |
| 3 | - | ||
| 4 | - | const log = createLogger('buddy-list-cache'); | |
| 5 | - | ||
| 6 | - | class BuddyListCache { | |
| 7 | - | private cache: SafeUser[] | null = null; | |
| 8 | - | private lastHash: string = ''; | |
| 9 | - | private lastFetch: number = 0; | |
| 10 | - | private isDirty: boolean = true; // Force initial fetch | |
| 11 | - | ||
| 12 | - | // Mark cache as needing refresh | |
| 13 | - | invalidate(): void { | |
| 14 | - | this.isDirty = true; | |
| 15 | - | log.debug('Buddy list cache invalidated'); | |
| 16 | - | } | |
| 17 | - | ||
| 18 | - | // Check if we need to fetch new data | |
| 19 | - | needsRefresh(): boolean { | |
| 20 | - | return this.isDirty || this.cache === null; | |
| 21 | - | } | |
| 22 | - | ||
| 23 | - | // Update cache with new data | |
| 24 | - | update(users: SafeUser[]): boolean { | |
| 25 | - | const newHash = JSON.stringify(users); | |
| 26 | - | const hasChanged = newHash !== this.lastHash; | |
| 27 | - | ||
| 28 | - | if (hasChanged) { | |
| 29 | - | this.cache = users; | |
| 30 | - | this.lastHash = newHash; | |
| 31 | - | this.lastFetch = Date.now(); | |
| 32 | - | this.isDirty = false; | |
| 33 | - | ||
| 34 | - | log.debug('Buddy list cache updated', { | |
| 35 | - | userCount: users.length, | |
| 36 | - | changed: hasChanged | |
| 37 | - | }); | |
| 38 | - | } | |
| 39 | - | ||
| 40 | - | return hasChanged; | |
| 41 | - | } | |
| 42 | - | ||
| 43 | - | // Get cached data | |
| 44 | - | get(): SafeUser[] | null { | |
| 45 | - | return this.cache; | |
| 46 | - | } | |
| 47 | - | ||
| 48 | - | // Get cache age in milliseconds | |
| 49 | - | getAge(): number { | |
| 50 | - | return this.cache ? Date.now() - this.lastFetch : Infinity; | |
| 51 | - | } | |
| 52 | - | } | |
| 53 | - | ||
| 54 | - | // Export singleton instance | |
| 55 | - | export const buddyListCache = new BuddyListCache(); | |
| @@ -1,55 +0,0 @@ | |||||
| 1 | - | import { createLogger } from './utils/logger.server'; | |||
| 2 | - | import type { SafeUser } from './types/chat'; | |||
| 3 | - | ||||
| 4 | - | const log = createLogger('buddy-list-cache'); | |||
| 5 | - | ||||
| 6 | - | class BuddyListCache { | |||
| 7 | - | private cache: SafeUser[] | null = null; | |||
| 8 | - | private lastHash: string = ''; | |||
| 9 | - | private lastFetch: number = 0; | |||
| 10 | - | private isDirty: boolean = true; // Force initial fetch | |||
| 11 | - | ||||
| 12 | - | // Mark cache as needing refresh | |||
| 13 | - | invalidate(): void { | |||
| 14 | - | this.isDirty = true; | |||
| 15 | - | log.debug('Buddy list cache invalidated'); | |||
| 16 | - | } | |||
| 17 | - | ||||
| 18 | - | // Check if we need to fetch new data | |||
| 19 | - | needsRefresh(): boolean { | |||
| 20 | - | return this.isDirty || this.cache === null; | |||
| 21 | - | } | |||
| 22 | - | ||||
| 23 | - | // Update cache with new data | |||
| 24 | - | update(users: SafeUser[]): boolean { | |||
| 25 | - | const newHash = JSON.stringify(users); | |||
| 26 | - | const hasChanged = newHash !== this.lastHash; | |||
| 27 | - | ||||
| 28 | - | if (hasChanged) { | |||
| 29 | - | this.cache = users; | |||
| 30 | - | this.lastHash = newHash; | |||
| 31 | - | this.lastFetch = Date.now(); | |||
| 32 | - | this.isDirty = false; | |||
| 33 | - | ||||
| 34 | - | log.debug('Buddy list cache updated', { | |||
| 35 | - | userCount: users.length, | |||
| 36 | - | changed: hasChanged | |||
| 37 | - | }); | |||
| 38 | - | } | |||
| 39 | - | ||||
| 40 | - | return hasChanged; | |||
| 41 | - | } | |||
| 42 | - | ||||
| 43 | - | // Get cached data | |||
| 44 | - | get(): SafeUser[] | null { | |||
| 45 | - | return this.cache; | |||
| 46 | - | } | |||
| 47 | - | ||||
| 48 | - | // Get cache age in milliseconds | |||
| 49 | - | getAge(): number { | |||
| 50 | - | return this.cache ? Date.now() - this.lastFetch : Infinity; | |||
| 51 | - | } | |||
| 52 | - | } | |||
| 53 | - | ||||
| 54 | - | // Export singleton instance | |||
| 55 | - | export const buddyListCache = new BuddyListCache(); | |||
D src/lib/db/db.server.ts +0 -39
| @@ -1,39 +0,0 @@ | |||
| 1 | - | import { drizzle } from 'drizzle-orm/libsql'; | |
| 2 | - | import { createClient } from '@libsql/client'; | |
| 3 | - | import { TURSO_AUTH_TOKEN, TURSO_DATABASE_URL } from '$env/static/private'; | |
| 4 | - | import schema from './schema'; | |
| 5 | - | import { ensureDefaultChatRoom } from '$lib/utils/chat.server'; | |
| 6 | - | import { createLogger } from '$lib/utils/logger.server'; | |
| 7 | - | ||
| 8 | - | const log = createLogger('db-server'); | |
| 9 | - | ||
| 10 | - | const client = createClient({ url: TURSO_DATABASE_URL, authToken: TURSO_AUTH_TOKEN }); | |
| 11 | - | const db = drizzle(client, { schema }); | |
| 12 | - | ||
| 13 | - | // Initialize database with required data | |
| 14 | - | export const initializeDatabase = async () => { | |
| 15 | - | log.debug('Initializing database...'); | |
| 16 | - | try { | |
| 17 | - | await ensureDefaultChatRoom(db); | |
| 18 | - | log.debug('Database initialization complete'); | |
| 19 | - | } catch (error) { | |
| 20 | - | log.error('Error initializing database:', { | |
| 21 | - | error: error instanceof Error ? error.message : 'Unknown error' | |
| 22 | - | }); | |
| 23 | - | throw error; | |
| 24 | - | } | |
| 25 | - | }; | |
| 26 | - | ||
| 27 | - | // Call initialization when the module is loaded | |
| 28 | - | initializeDatabase().catch((error) => { | |
| 29 | - | log.error('Failed to initialize database:', { | |
| 30 | - | error: error instanceof Error ? error.message : 'Unknown error' | |
| 31 | - | }); | |
| 32 | - | }); | |
| 33 | - | ||
| 34 | - | export const testConnection = async () => { | |
| 35 | - | const result = await db.query.users.findMany(); | |
| 36 | - | log.debug('Test connection result:', result); | |
| 37 | - | }; | |
| 38 | - | ||
| 39 | - | export default db; | |
| @@ -1,39 +0,0 @@ | |||||
| 1 | - | import { drizzle } from 'drizzle-orm/libsql'; | |||
| 2 | - | import { createClient } from '@libsql/client'; | |||
| 3 | - | import { TURSO_AUTH_TOKEN, TURSO_DATABASE_URL } from '$env/static/private'; | |||
| 4 | - | import schema from './schema'; | |||
| 5 | - | import { ensureDefaultChatRoom } from '$lib/utils/chat.server'; | |||
| 6 | - | import { createLogger } from '$lib/utils/logger.server'; | |||
| 7 | - | ||||
| 8 | - | const log = createLogger('db-server'); | |||
| 9 | - | ||||
| 10 | - | const client = createClient({ url: TURSO_DATABASE_URL, authToken: TURSO_AUTH_TOKEN }); | |||
| 11 | - | const db = drizzle(client, { schema }); | |||
| 12 | - | ||||
| 13 | - | // Initialize database with required data | |||
| 14 | - | export const initializeDatabase = async () => { | |||
| 15 | - | log.debug('Initializing database...'); | |||
| 16 | - | try { | |||
| 17 | - | await ensureDefaultChatRoom(db); | |||
| 18 | - | log.debug('Database initialization complete'); | |||
| 19 | - | } catch (error) { | |||
| 20 | - | log.error('Error initializing database:', { | |||
| 21 | - | error: error instanceof Error ? error.message : 'Unknown error' | |||
| 22 | - | }); | |||
| 23 | - | throw error; | |||
| 24 | - | } | |||
| 25 | - | }; | |||
| 26 | - | ||||
| 27 | - | // Call initialization when the module is loaded | |||
| 28 | - | initializeDatabase().catch((error) => { | |||
| 29 | - | log.error('Failed to initialize database:', { | |||
| 30 | - | error: error instanceof Error ? error.message : 'Unknown error' | |||
| 31 | - | }); | |||
| 32 | - | }); | |||
| 33 | - | ||||
| 34 | - | export const testConnection = async () => { | |||
| 35 | - | const result = await db.query.users.findMany(); | |||
| 36 | - | log.debug('Test connection result:', result); | |||
| 37 | - | }; | |||
| 38 | - | ||||
| 39 | - | export default db; | |||
D src/lib/db/flush.ts +0 -54
| @@ -1,54 +0,0 @@ | |||
| 1 | - | import { createClient } from '@libsql/client'; | |
| 2 | - | import * as dotenv from 'dotenv'; | |
| 3 | - | ||
| 4 | - | // Load environment variables from .env file | |
| 5 | - | dotenv.config(); | |
| 6 | - | ||
| 7 | - | const { TURSO_DATABASE_URL, TURSO_AUTH_TOKEN } = process.env; | |
| 8 | - | ||
| 9 | - | if (!TURSO_DATABASE_URL || !TURSO_AUTH_TOKEN) { | |
| 10 | - | throw new Error( | |
| 11 | - | 'Missing required environment variables TURSO_DATABASE_URL and/or TURSO_AUTH_TOKEN' | |
| 12 | - | ); | |
| 13 | - | } | |
| 14 | - | ||
| 15 | - | async function flushDatabase() { | |
| 16 | - | console.debug('Starting database content flush...'); | |
| 17 | - | ||
| 18 | - | const client = createClient({ | |
| 19 | - | url: TURSO_DATABASE_URL as string, | |
| 20 | - | authToken: TURSO_AUTH_TOKEN as string | |
| 21 | - | }); | |
| 22 | - | ||
| 23 | - | try { | |
| 24 | - | // Clear tables in correct order to respect foreign key constraints | |
| 25 | - | console.debug('Clearing messages table...'); | |
| 26 | - | await client.execute('DELETE FROM messages'); | |
| 27 | - | ||
| 28 | - | console.debug('Clearing sessions table...'); | |
| 29 | - | await client.execute('DELETE FROM sessions'); | |
| 30 | - | ||
| 31 | - | console.debug('Clearing chat rooms table...'); | |
| 32 | - | await client.execute('DELETE FROM chat_rooms'); | |
| 33 | - | ||
| 34 | - | console.debug('Clearing users table...'); | |
| 35 | - | await client.execute('DELETE FROM users'); | |
| 36 | - | ||
| 37 | - | console.debug('Database content flush completed successfully'); | |
| 38 | - | } catch (error) { | |
| 39 | - | console.error('Error flushing database content:', error); | |
| 40 | - | throw error; | |
| 41 | - | } finally { | |
| 42 | - | await client.close(); | |
| 43 | - | } | |
| 44 | - | } | |
| 45 | - | ||
| 46 | - | // Execute if this file is run directly | |
| 47 | - | if (process.argv[1] === import.meta.url) { | |
| 48 | - | flushDatabase() | |
| 49 | - | .then(() => process.exit(0)) | |
| 50 | - | .catch((error) => { | |
| 51 | - | console.error('Failed to flush database content:', error); | |
| 52 | - | process.exit(1); | |
| 53 | - | }); | |
| 54 | - | } | |
| @@ -1,54 +0,0 @@ | |||||
| 1 | - | import { createClient } from '@libsql/client'; | |||
| 2 | - | import * as dotenv from 'dotenv'; | |||
| 3 | - | ||||
| 4 | - | // Load environment variables from .env file | |||
| 5 | - | dotenv.config(); | |||
| 6 | - | ||||
| 7 | - | const { TURSO_DATABASE_URL, TURSO_AUTH_TOKEN } = process.env; | |||
| 8 | - | ||||
| 9 | - | if (!TURSO_DATABASE_URL || !TURSO_AUTH_TOKEN) { | |||
| 10 | - | throw new Error( | |||
| 11 | - | 'Missing required environment variables TURSO_DATABASE_URL and/or TURSO_AUTH_TOKEN' | |||
| 12 | - | ); | |||
| 13 | - | } | |||
| 14 | - | ||||
| 15 | - | async function flushDatabase() { | |||
| 16 | - | console.debug('Starting database content flush...'); | |||
| 17 | - | ||||
| 18 | - | const client = createClient({ | |||
| 19 | - | url: TURSO_DATABASE_URL as string, | |||
| 20 | - | authToken: TURSO_AUTH_TOKEN as string | |||
| 21 | - | }); | |||
| 22 | - | ||||
| 23 | - | try { | |||
| 24 | - | // Clear tables in correct order to respect foreign key constraints | |||
| 25 | - | console.debug('Clearing messages table...'); | |||
| 26 | - | await client.execute('DELETE FROM messages'); | |||
| 27 | - | ||||
| 28 | - | console.debug('Clearing sessions table...'); | |||
| 29 | - | await client.execute('DELETE FROM sessions'); | |||
| 30 | - | ||||
| 31 | - | console.debug('Clearing chat rooms table...'); | |||
| 32 | - | await client.execute('DELETE FROM chat_rooms'); | |||
| 33 | - | ||||
| 34 | - | console.debug('Clearing users table...'); | |||
| 35 | - | await client.execute('DELETE FROM users'); | |||
| 36 | - | ||||
| 37 | - | console.debug('Database content flush completed successfully'); | |||
| 38 | - | } catch (error) { | |||
| 39 | - | console.error('Error flushing database content:', error); | |||
| 40 | - | throw error; | |||
| 41 | - | } finally { | |||
| 42 | - | await client.close(); | |||
| 43 | - | } | |||
| 44 | - | } | |||
| 45 | - | ||||
| 46 | - | // Execute if this file is run directly | |||
| 47 | - | if (process.argv[1] === import.meta.url) { | |||
| 48 | - | flushDatabase() | |||
| 49 | - | .then(() => process.exit(0)) | |||
| 50 | - | .catch((error) => { | |||
| 51 | - | console.error('Failed to flush database content:', error); | |||
| 52 | - | process.exit(1); | |||
| 53 | - | }); | |||
| 54 | - | } | |||
D src/lib/db/schema.ts +0 -138
| @@ -1,138 +0,0 @@ | |||
| 1 | - | import { sqliteTable as table } from 'drizzle-orm/sqlite-core'; | |
| 2 | - | import * as t from 'drizzle-orm/sqlite-core'; | |
| 3 | - | import type { User, ChatRoom, Message, UserStatus, MessageType, Session } from '../types/chat'; | |
| 4 | - | import { v4 as uuidv4 } from 'uuid'; | |
| 5 | - | import { eq } from 'drizzle-orm'; | |
| 6 | - | ||
| 7 | - | export const users = table('users', { | |
| 8 | - | id: t | |
| 9 | - | .text('id') | |
| 10 | - | .primaryKey() | |
| 11 | - | .$default(() => uuidv4()), | |
| 12 | - | password: t.text('password').notNull(), | |
| 13 | - | nickname: t.text('nickname').notNull(), | |
| 14 | - | status: t.text('status').notNull().$type<UserStatus>().default('offline'), | |
| 15 | - | avatarUrl: t.text('avatar_url'), | |
| 16 | - | createdAt: t.integer('created_at').notNull(), | |
| 17 | - | lastSeen: t.integer('last_seen') | |
| 18 | - | }); | |
| 19 | - | ||
| 20 | - | export const sessions = table('sessions', { | |
| 21 | - | id: t.text('id').primaryKey(), | |
| 22 | - | userId: t | |
| 23 | - | .text('user_id') | |
| 24 | - | .references(() => users.id) | |
| 25 | - | .notNull(), | |
| 26 | - | expiresAt: t.integer('expires_at').notNull(), | |
| 27 | - | createdAt: t.integer('created_at').notNull() | |
| 28 | - | }); | |
| 29 | - | ||
| 30 | - | export const chatRooms = table('chat_rooms', { | |
| 31 | - | id: t | |
| 32 | - | .text('id') | |
| 33 | - | .primaryKey() | |
| 34 | - | .$default(() => uuidv4()), | |
| 35 | - | name: t.text('name'), | |
| 36 | - | type: t.text('type').$type<'direct' | 'group'>().notNull().default('direct'), | |
| 37 | - | createdAt: t.integer('created_at').notNull() | |
| 38 | - | }); | |
| 39 | - | ||
| 40 | - | export const messages = table('messages', { | |
| 41 | - | id: t | |
| 42 | - | .text('id') | |
| 43 | - | .primaryKey() | |
| 44 | - | .$default(() => uuidv4()), | |
| 45 | - | chatRoomId: t | |
| 46 | - | .text('chat_room_id') | |
| 47 | - | .references(() => chatRooms.id) | |
| 48 | - | .notNull(), | |
| 49 | - | senderId: t | |
| 50 | - | .text('sender_id') | |
| 51 | - | .references(() => users.id) | |
| 52 | - | .notNull(), | |
| 53 | - | content: t.text('content').notNull(), | |
| 54 | - | type: t.text('type').$type<MessageType>().notNull().default('chat'), | |
| 55 | - | timestamp: t.integer('timestamp').notNull(), | |
| 56 | - | styleData: t.text('style_data'), // JSON string of TextStyle object | |
| 57 | - | hasFormatting: t.integer('has_formatting', { mode: 'boolean' }).default(false) // Boolean flag | |
| 58 | - | }); | |
| 59 | - | ||
| 60 | - | export const userTextPreferences = table('user_text_preferences', { | |
| 61 | - | userId: t | |
| 62 | - | .text('user_id') | |
| 63 | - | .references(() => users.id) | |
| 64 | - | .primaryKey(), | |
| 65 | - | defaultFontFamily: t.text('default_font_family').default('tahoma'), | |
| 66 | - | defaultFontSize: t.integer('default_font_size').default(14), | |
| 67 | - | defaultColor: t.text('default_color').default('black'), | |
| 68 | - | allowFormatting: t.integer('allow_formatting', { mode: 'boolean' }).default(true), | |
| 69 | - | maxMessageLength: t.integer('max_message_length').default(500), | |
| 70 | - | stylePresets: t.text('style_presets'), // JSON array of saved styles | |
| 71 | - | createdAt: t.integer('created_at').notNull(), | |
| 72 | - | updatedAt: t.integer('updated_at').notNull() | |
| 73 | - | }); | |
| 74 | - | ||
| 75 | - | // Validate schema types against interfaces | |
| 76 | - | export type Users = typeof users.$inferSelect; | |
| 77 | - | export type ChatRooms = typeof chatRooms.$inferSelect; | |
| 78 | - | export type Messages = typeof messages.$inferSelect; | |
| 79 | - | export type Sessions = typeof sessions.$inferSelect; | |
| 80 | - | export type UserTextPreferences = typeof userTextPreferences.$inferSelect; | |
| 81 | - | // These type assertions will fail if the schema doesn't match the interfaces | |
| 82 | - | export type _UsersValidation = Omit<User, keyof Users> & Omit<Users, keyof User>; | |
| 83 | - | export type _ChatRoomsValidation = Omit<ChatRoom, keyof ChatRooms> & | |
| 84 | - | Omit<ChatRooms, keyof ChatRoom>; | |
| 85 | - | export type _MessagesValidation = Omit<Message, keyof Messages> & Omit<Messages, keyof Message>; | |
| 86 | - | export type _SessionsValidation = Omit<Session, keyof Sessions> & Omit<Sessions, keyof Session>; | |
| 87 | - | ||
| 88 | - | export const userView = t.sqliteView('user_view').as((qb) => | |
| 89 | - | qb | |
| 90 | - | .select({ | |
| 91 | - | id: users.id, | |
| 92 | - | nickname: users.nickname, | |
| 93 | - | status: users.status, | |
| 94 | - | avatarUrl: users.avatarUrl, | |
| 95 | - | lastSeen: users.lastSeen | |
| 96 | - | }) | |
| 97 | - | .from(users) | |
| 98 | - | ); | |
| 99 | - | ||
| 100 | - | export const chatRoomView = t.sqliteView('chat_room_view').as((qb) => | |
| 101 | - | qb | |
| 102 | - | .select({ | |
| 103 | - | id: chatRooms.id, | |
| 104 | - | name: chatRooms.name, | |
| 105 | - | type: chatRooms.type, | |
| 106 | - | createdAt: chatRooms.createdAt | |
| 107 | - | }) | |
| 108 | - | .from(chatRooms) | |
| 109 | - | ); | |
| 110 | - | ||
| 111 | - | export const messageView = t.sqliteView('message_view').as((qb) => | |
| 112 | - | qb | |
| 113 | - | .select({ | |
| 114 | - | id: messages.id, | |
| 115 | - | content: messages.content, | |
| 116 | - | type: messages.type, | |
| 117 | - | timestamp: messages.timestamp, | |
| 118 | - | sender: users.nickname, | |
| 119 | - | chatRoom: chatRooms.name | |
| 120 | - | }) | |
| 121 | - | .from(messages) | |
| 122 | - | .leftJoin(users, eq(messages.senderId, users.id)) | |
| 123 | - | .leftJoin(chatRooms, eq(messages.chatRoomId, chatRooms.id)) | |
| 124 | - | ); | |
| 125 | - | ||
| 126 | - | // Create a schema object with all our tables and views | |
| 127 | - | const schema = { | |
| 128 | - | users, | |
| 129 | - | sessions, | |
| 130 | - | chatRooms, | |
| 131 | - | messages, | |
| 132 | - | userTextPreferences, | |
| 133 | - | userView, | |
| 134 | - | chatRoomView, | |
| 135 | - | messageView | |
| 136 | - | }; | |
| 137 | - | ||
| 138 | - | export default schema; | |
| @@ -1,138 +0,0 @@ | |||||
| 1 | - | import { sqliteTable as table } from 'drizzle-orm/sqlite-core'; | |||
| 2 | - | import * as t from 'drizzle-orm/sqlite-core'; | |||
| 3 | - | import type { User, ChatRoom, Message, UserStatus, MessageType, Session } from '../types/chat'; | |||
| 4 | - | import { v4 as uuidv4 } from 'uuid'; | |||
| 5 | - | import { eq } from 'drizzle-orm'; | |||
| 6 | - | ||||
| 7 | - | export const users = table('users', { | |||
| 8 | - | id: t | |||
| 9 | - | .text('id') | |||
| 10 | - | .primaryKey() | |||
| 11 | - | .$default(() => uuidv4()), | |||
| 12 | - | password: t.text('password').notNull(), | |||
| 13 | - | nickname: t.text('nickname').notNull(), | |||
| 14 | - | status: t.text('status').notNull().$type<UserStatus>().default('offline'), | |||
| 15 | - | avatarUrl: t.text('avatar_url'), | |||
| 16 | - | createdAt: t.integer('created_at').notNull(), | |||
| 17 | - | lastSeen: t.integer('last_seen') | |||
| 18 | - | }); | |||
| 19 | - | ||||
| 20 | - | export const sessions = table('sessions', { | |||
| 21 | - | id: t.text('id').primaryKey(), | |||
| 22 | - | userId: t | |||
| 23 | - | .text('user_id') | |||
| 24 | - | .references(() => users.id) | |||
| 25 | - | .notNull(), | |||
| 26 | - | expiresAt: t.integer('expires_at').notNull(), | |||
| 27 | - | createdAt: t.integer('created_at').notNull() | |||
| 28 | - | }); | |||
| 29 | - | ||||
| 30 | - | export const chatRooms = table('chat_rooms', { | |||
| 31 | - | id: t | |||
| 32 | - | .text('id') | |||
| 33 | - | .primaryKey() | |||
| 34 | - | .$default(() => uuidv4()), | |||
| 35 | - | name: t.text('name'), | |||
| 36 | - | type: t.text('type').$type<'direct' | 'group'>().notNull().default('direct'), | |||
| 37 | - | createdAt: t.integer('created_at').notNull() | |||
| 38 | - | }); | |||
| 39 | - | ||||
| 40 | - | export const messages = table('messages', { | |||
| 41 | - | id: t | |||
| 42 | - | .text('id') | |||
| 43 | - | .primaryKey() | |||
| 44 | - | .$default(() => uuidv4()), | |||
| 45 | - | chatRoomId: t | |||
| 46 | - | .text('chat_room_id') | |||
| 47 | - | .references(() => chatRooms.id) | |||
| 48 | - | .notNull(), | |||
| 49 | - | senderId: t | |||
| 50 | - | .text('sender_id') | |||
| 51 | - | .references(() => users.id) | |||
| 52 | - | .notNull(), | |||
| 53 | - | content: t.text('content').notNull(), | |||
| 54 | - | type: t.text('type').$type<MessageType>().notNull().default('chat'), | |||
| 55 | - | timestamp: t.integer('timestamp').notNull(), | |||
| 56 | - | styleData: t.text('style_data'), // JSON string of TextStyle object | |||
| 57 | - | hasFormatting: t.integer('has_formatting', { mode: 'boolean' }).default(false) // Boolean flag | |||
| 58 | - | }); | |||
| 59 | - | ||||
| 60 | - | export const userTextPreferences = table('user_text_preferences', { | |||
| 61 | - | userId: t | |||
| 62 | - | .text('user_id') | |||
| 63 | - | .references(() => users.id) | |||
| 64 | - | .primaryKey(), | |||
| 65 | - | defaultFontFamily: t.text('default_font_family').default('tahoma'), | |||
| 66 | - | defaultFontSize: t.integer('default_font_size').default(14), | |||
| 67 | - | defaultColor: t.text('default_color').default('black'), | |||
| 68 | - | allowFormatting: t.integer('allow_formatting', { mode: 'boolean' }).default(true), | |||
| 69 | - | maxMessageLength: t.integer('max_message_length').default(500), | |||
| 70 | - | stylePresets: t.text('style_presets'), // JSON array of saved styles | |||
| 71 | - | createdAt: t.integer('created_at').notNull(), | |||
| 72 | - | updatedAt: t.integer('updated_at').notNull() | |||
| 73 | - | }); | |||
| 74 | - | ||||
| 75 | - | // Validate schema types against interfaces | |||
| 76 | - | export type Users = typeof users.$inferSelect; | |||
| 77 | - | export type ChatRooms = typeof chatRooms.$inferSelect; | |||
| 78 | - | export type Messages = typeof messages.$inferSelect; | |||
| 79 | - | export type Sessions = typeof sessions.$inferSelect; | |||
| 80 | - | export type UserTextPreferences = typeof userTextPreferences.$inferSelect; | |||
| 81 | - | // These type assertions will fail if the schema doesn't match the interfaces | |||
| 82 | - | export type _UsersValidation = Omit<User, keyof Users> & Omit<Users, keyof User>; | |||
| 83 | - | export type _ChatRoomsValidation = Omit<ChatRoom, keyof ChatRooms> & | |||
| 84 | - | Omit<ChatRooms, keyof ChatRoom>; | |||
| 85 | - | export type _MessagesValidation = Omit<Message, keyof Messages> & Omit<Messages, keyof Message>; | |||
| 86 | - | export type _SessionsValidation = Omit<Session, keyof Sessions> & Omit<Sessions, keyof Session>; | |||
| 87 | - | ||||
| 88 | - | export const userView = t.sqliteView('user_view').as((qb) => | |||
| 89 | - | qb | |||
| 90 | - | .select({ | |||
| 91 | - | id: users.id, | |||
| 92 | - | nickname: users.nickname, | |||
| 93 | - | status: users.status, | |||
| 94 | - | avatarUrl: users.avatarUrl, | |||
| 95 | - | lastSeen: users.lastSeen | |||
| 96 | - | }) | |||
| 97 | - | .from(users) | |||
| 98 | - | ); | |||
| 99 | - | ||||
| 100 | - | export const chatRoomView = t.sqliteView('chat_room_view').as((qb) => | |||
| 101 | - | qb | |||
| 102 | - | .select({ | |||
| 103 | - | id: chatRooms.id, | |||
| 104 | - | name: chatRooms.name, | |||
| 105 | - | type: chatRooms.type, | |||
| 106 | - | createdAt: chatRooms.createdAt | |||
| 107 | - | }) | |||
| 108 | - | .from(chatRooms) | |||
| 109 | - | ); | |||
| 110 | - | ||||
| 111 | - | export const messageView = t.sqliteView('message_view').as((qb) => | |||
| 112 | - | qb | |||
| 113 | - | .select({ | |||
| 114 | - | id: messages.id, | |||
| 115 | - | content: messages.content, | |||
| 116 | - | type: messages.type, | |||
| 117 | - | timestamp: messages.timestamp, | |||
| 118 | - | sender: users.nickname, | |||
| 119 | - | chatRoom: chatRooms.name | |||
| 120 | - | }) | |||
| 121 | - | .from(messages) | |||
| 122 | - | .leftJoin(users, eq(messages.senderId, users.id)) | |||
| 123 | - | .leftJoin(chatRooms, eq(messages.chatRoomId, chatRooms.id)) | |||
| 124 | - | ); | |||
| 125 | - | ||||
| 126 | - | // Create a schema object with all our tables and views | |||
| 127 | - | const schema = { | |||
| 128 | - | users, | |||
| 129 | - | sessions, | |||
| 130 | - | chatRooms, | |||
| 131 | - | messages, | |||
| 132 | - | userTextPreferences, | |||
| 133 | - | userView, | |||
| 134 | - | chatRoomView, | |||
| 135 | - | messageView | |||
| 136 | - | }; | |||
| 137 | - | ||||
| 138 | - | export default schema; | |||
D utils/db-flush.ts +0 -57
| @@ -1,57 +0,0 @@ | |||
| 1 | - | import { createClient } from '@libsql/client'; | |
| 2 | - | import * as dotenv from 'dotenv'; | |
| 3 | - | ||
| 4 | - | // Load environment variables from .env file | |
| 5 | - | dotenv.config(); | |
| 6 | - | ||
| 7 | - | const { TURSO_DATABASE_URL, TURSO_AUTH_TOKEN } = process.env; | |
| 8 | - | ||
| 9 | - | if (!TURSO_DATABASE_URL || !TURSO_AUTH_TOKEN) { | |
| 10 | - | throw new Error( | |
| 11 | - | 'Missing required environment variables TURSO_DATABASE_URL and/or TURSO_AUTH_TOKEN' | |
| 12 | - | ); | |
| 13 | - | } | |
| 14 | - | ||
| 15 | - | async function flushDatabase() { | |
| 16 | - | console.log('Starting database content flush...'); | |
| 17 | - | ||
| 18 | - | const client = createClient({ | |
| 19 | - | url: TURSO_DATABASE_URL as string, | |
| 20 | - | authToken: TURSO_AUTH_TOKEN as string | |
| 21 | - | }); | |
| 22 | - | ||
| 23 | - | try { | |
| 24 | - | // Clear tables in correct order to respect foreign key constraints | |
| 25 | - | console.log('Clearing messages table...'); | |
| 26 | - | await client.execute('DELETE FROM messages'); | |
| 27 | - | ||
| 28 | - | console.log('Clearing sessions table...'); | |
| 29 | - | await client.execute('DELETE FROM sessions'); | |
| 30 | - | ||
| 31 | - | console.log('Clearing chat rooms table...'); | |
| 32 | - | await client.execute('DELETE FROM chat_rooms'); | |
| 33 | - | ||
| 34 | - | console.log('Clearing users table...'); | |
| 35 | - | await client.execute('DELETE FROM users'); | |
| 36 | - | ||
| 37 | - | console.log('Database content flush completed successfully'); | |
| 38 | - | } catch (error) { | |
| 39 | - | console.error('Error flushing database content:', error); | |
| 40 | - | throw error; | |
| 41 | - | } finally { | |
| 42 | - | await client.close(); | |
| 43 | - | } | |
| 44 | - | } | |
| 45 | - | ||
| 46 | - | // Execute if this file is run directly | |
| 47 | - | if (new URL(import.meta.url).pathname === process.argv[1]) { | |
| 48 | - | flushDatabase() | |
| 49 | - | .then(() => { | |
| 50 | - | console.debug('[db-flush] Exiting process with code 0'); | |
| 51 | - | process.exit(0); | |
| 52 | - | }) | |
| 53 | - | .catch((error) => { | |
| 54 | - | console.error('[db-flush] Failed to flush database content:', error); | |
| 55 | - | process.exit(1); | |
| 56 | - | }); | |
| 57 | - | } | |
| @@ -1,57 +0,0 @@ | |||||
| 1 | - | import { createClient } from '@libsql/client'; | |||
| 2 | - | import * as dotenv from 'dotenv'; | |||
| 3 | - | ||||
| 4 | - | // Load environment variables from .env file | |||
| 5 | - | dotenv.config(); | |||
| 6 | - | ||||
| 7 | - | const { TURSO_DATABASE_URL, TURSO_AUTH_TOKEN } = process.env; | |||
| 8 | - | ||||
| 9 | - | if (!TURSO_DATABASE_URL || !TURSO_AUTH_TOKEN) { | |||
| 10 | - | throw new Error( | |||
| 11 | - | 'Missing required environment variables TURSO_DATABASE_URL and/or TURSO_AUTH_TOKEN' | |||
| 12 | - | ); | |||
| 13 | - | } | |||
| 14 | - | ||||
| 15 | - | async function flushDatabase() { | |||
| 16 | - | console.log('Starting database content flush...'); | |||
| 17 | - | ||||
| 18 | - | const client = createClient({ | |||
| 19 | - | url: TURSO_DATABASE_URL as string, | |||
| 20 | - | authToken: TURSO_AUTH_TOKEN as string | |||
| 21 | - | }); | |||
| 22 | - | ||||
| 23 | - | try { | |||
| 24 | - | // Clear tables in correct order to respect foreign key constraints | |||
| 25 | - | console.log('Clearing messages table...'); | |||
| 26 | - | await client.execute('DELETE FROM messages'); | |||
| 27 | - | ||||
| 28 | - | console.log('Clearing sessions table...'); | |||
| 29 | - | await client.execute('DELETE FROM sessions'); | |||
| 30 | - | ||||
| 31 | - | console.log('Clearing chat rooms table...'); | |||
| 32 | - | await client.execute('DELETE FROM chat_rooms'); | |||
| 33 | - | ||||
| 34 | - | console.log('Clearing users table...'); | |||
| 35 | - | await client.execute('DELETE FROM users'); | |||
| 36 | - | ||||
| 37 | - | console.log('Database content flush completed successfully'); | |||
| 38 | - | } catch (error) { | |||
| 39 | - | console.error('Error flushing database content:', error); | |||
| 40 | - | throw error; | |||
| 41 | - | } finally { | |||
| 42 | - | await client.close(); | |||
| 43 | - | } | |||
| 44 | - | } | |||
| 45 | - | ||||
| 46 | - | // Execute if this file is run directly | |||
| 47 | - | if (new URL(import.meta.url).pathname === process.argv[1]) { | |||
| 48 | - | flushDatabase() | |||
| 49 | - | .then(() => { | |||
| 50 | - | console.debug('[db-flush] Exiting process with code 0'); | |||
| 51 | - | process.exit(0); | |||
| 52 | - | }) | |||
| 53 | - | .catch((error) => { | |||
| 54 | - | console.error('[db-flush] Failed to flush database content:', error); | |||
| 55 | - | process.exit(1); | |||
| 56 | - | }); | |||
| 57 | - | } | |||