My personal site. theclashfruit.me
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: finish the db schema

+1003 -5
+9
.drizzle/0004_previous_gideon.sql
··· 1 + CREATE TABLE "posts_images" ( 2 + "id" bigint PRIMARY KEY NOT NULL, 3 + "post_id" bigint, 4 + "hash" varchar(40) NOT NULL, 5 + "name" varchar(1024) NOT NULL, 6 + CONSTRAINT "posts_images_hash_unique" UNIQUE("hash") 7 + ); 8 + --> statement-breakpoint 9 + ALTER TABLE "posts_images" ADD CONSTRAINT "posts_images_post_id_posts_id_fk" FOREIGN KEY ("post_id") REFERENCES "public"."posts"("id") ON DELETE cascade ON UPDATE no action;
+24
.drizzle/0005_slow_songbird.sql
··· 1 + CREATE TYPE "public"."gallery_type" AS ENUM('art', 'picture');--> statement-breakpoint 2 + CREATE TABLE "gallery_images" ( 3 + "id" bigint PRIMARY KEY NOT NULL, 4 + "art_id" bigint, 5 + "hash" varchar(40) NOT NULL, 6 + "name" varchar(1024) NOT NULL, 7 + "alt" text NOT NULL, 8 + "main" boolean DEFAULT false NOT NULL, 9 + CONSTRAINT "gallery_images_hash_unique" UNIQUE("hash") 10 + ); 11 + --> statement-breakpoint 12 + CREATE TABLE "gallery" ( 13 + "id" bigint PRIMARY KEY NOT NULL, 14 + "type" "gallery_type" NOT NULL, 15 + "slug" varchar(128) NOT NULL, 16 + "title" varchar(256) NOT NULL, 17 + "content" text NOT NULL, 18 + "draft" boolean DEFAULT true NOT NULL, 19 + "published_at" timestamp DEFAULT now() NOT NULL, 20 + "updated_at" timestamp DEFAULT now() NOT NULL, 21 + CONSTRAINT "gallery_slug_unique" UNIQUE("slug") 22 + ); 23 + --> statement-breakpoint 24 + ALTER TABLE "gallery_images" ADD CONSTRAINT "gallery_images_art_id_gallery_id_fk" FOREIGN KEY ("art_id") REFERENCES "public"."gallery"("id") ON DELETE cascade ON UPDATE no action;
+337
.drizzle/meta/0004_snapshot.json
··· 1 + { 2 + "id": "7c936126-194c-4f96-b833-ab8bd06b726e", 3 + "prevId": "d4271530-af67-49ae-a6df-f87645ab4cc5", 4 + "version": "7", 5 + "dialect": "postgresql", 6 + "tables": { 7 + "public.comments": { 8 + "name": "comments", 9 + "schema": "", 10 + "columns": { 11 + "id": { 12 + "name": "id", 13 + "type": "bigint", 14 + "primaryKey": true, 15 + "notNull": true 16 + }, 17 + "post_id": { 18 + "name": "post_id", 19 + "type": "bigint", 20 + "primaryKey": false, 21 + "notNull": false 22 + }, 23 + "parent_id": { 24 + "name": "parent_id", 25 + "type": "bigint", 26 + "primaryKey": false, 27 + "notNull": false 28 + }, 29 + "author_id": { 30 + "name": "author_id", 31 + "type": "bigint", 32 + "primaryKey": false, 33 + "notNull": false 34 + }, 35 + "display_name": { 36 + "name": "display_name", 37 + "type": "varchar(64)", 38 + "primaryKey": false, 39 + "notNull": false 40 + }, 41 + "content": { 42 + "name": "content", 43 + "type": "text", 44 + "primaryKey": false, 45 + "notNull": true 46 + } 47 + }, 48 + "indexes": {}, 49 + "foreignKeys": { 50 + "comments_post_id_posts_id_fk": { 51 + "name": "comments_post_id_posts_id_fk", 52 + "tableFrom": "comments", 53 + "tableTo": "posts", 54 + "columnsFrom": [ 55 + "post_id" 56 + ], 57 + "columnsTo": [ 58 + "id" 59 + ], 60 + "onDelete": "cascade", 61 + "onUpdate": "no action" 62 + }, 63 + "comments_parent_id_comments_id_fk": { 64 + "name": "comments_parent_id_comments_id_fk", 65 + "tableFrom": "comments", 66 + "tableTo": "comments", 67 + "columnsFrom": [ 68 + "parent_id" 69 + ], 70 + "columnsTo": [ 71 + "id" 72 + ], 73 + "onDelete": "cascade", 74 + "onUpdate": "no action" 75 + }, 76 + "comments_author_id_users_id_fk": { 77 + "name": "comments_author_id_users_id_fk", 78 + "tableFrom": "comments", 79 + "tableTo": "users", 80 + "columnsFrom": [ 81 + "author_id" 82 + ], 83 + "columnsTo": [ 84 + "id" 85 + ], 86 + "onDelete": "cascade", 87 + "onUpdate": "no action" 88 + } 89 + }, 90 + "compositePrimaryKeys": {}, 91 + "uniqueConstraints": {}, 92 + "policies": {}, 93 + "checkConstraints": {}, 94 + "isRLSEnabled": false 95 + }, 96 + "public.posts_images": { 97 + "name": "posts_images", 98 + "schema": "", 99 + "columns": { 100 + "id": { 101 + "name": "id", 102 + "type": "bigint", 103 + "primaryKey": true, 104 + "notNull": true 105 + }, 106 + "post_id": { 107 + "name": "post_id", 108 + "type": "bigint", 109 + "primaryKey": false, 110 + "notNull": false 111 + }, 112 + "hash": { 113 + "name": "hash", 114 + "type": "varchar(40)", 115 + "primaryKey": false, 116 + "notNull": true 117 + }, 118 + "name": { 119 + "name": "name", 120 + "type": "varchar(1024)", 121 + "primaryKey": false, 122 + "notNull": true 123 + } 124 + }, 125 + "indexes": {}, 126 + "foreignKeys": { 127 + "posts_images_post_id_posts_id_fk": { 128 + "name": "posts_images_post_id_posts_id_fk", 129 + "tableFrom": "posts_images", 130 + "tableTo": "posts", 131 + "columnsFrom": [ 132 + "post_id" 133 + ], 134 + "columnsTo": [ 135 + "id" 136 + ], 137 + "onDelete": "cascade", 138 + "onUpdate": "no action" 139 + } 140 + }, 141 + "compositePrimaryKeys": {}, 142 + "uniqueConstraints": { 143 + "posts_images_hash_unique": { 144 + "name": "posts_images_hash_unique", 145 + "nullsNotDistinct": false, 146 + "columns": [ 147 + "hash" 148 + ] 149 + } 150 + }, 151 + "policies": {}, 152 + "checkConstraints": {}, 153 + "isRLSEnabled": false 154 + }, 155 + "public.posts": { 156 + "name": "posts", 157 + "schema": "", 158 + "columns": { 159 + "id": { 160 + "name": "id", 161 + "type": "bigint", 162 + "primaryKey": true, 163 + "notNull": true 164 + }, 165 + "author_id": { 166 + "name": "author_id", 167 + "type": "bigint", 168 + "primaryKey": false, 169 + "notNull": false 170 + }, 171 + "slug": { 172 + "name": "slug", 173 + "type": "varchar(128)", 174 + "primaryKey": false, 175 + "notNull": true 176 + }, 177 + "title": { 178 + "name": "title", 179 + "type": "varchar(256)", 180 + "primaryKey": false, 181 + "notNull": true 182 + }, 183 + "excerpt": { 184 + "name": "excerpt", 185 + "type": "text", 186 + "primaryKey": false, 187 + "notNull": true 188 + }, 189 + "content": { 190 + "name": "content", 191 + "type": "text", 192 + "primaryKey": false, 193 + "notNull": true 194 + }, 195 + "draft": { 196 + "name": "draft", 197 + "type": "boolean", 198 + "primaryKey": false, 199 + "notNull": true, 200 + "default": true 201 + }, 202 + "published_at": { 203 + "name": "published_at", 204 + "type": "timestamp", 205 + "primaryKey": false, 206 + "notNull": true, 207 + "default": "now()" 208 + }, 209 + "updated_at": { 210 + "name": "updated_at", 211 + "type": "timestamp", 212 + "primaryKey": false, 213 + "notNull": true, 214 + "default": "now()" 215 + } 216 + }, 217 + "indexes": {}, 218 + "foreignKeys": { 219 + "posts_author_id_users_id_fk": { 220 + "name": "posts_author_id_users_id_fk", 221 + "tableFrom": "posts", 222 + "tableTo": "users", 223 + "columnsFrom": [ 224 + "author_id" 225 + ], 226 + "columnsTo": [ 227 + "id" 228 + ], 229 + "onDelete": "cascade", 230 + "onUpdate": "no action" 231 + } 232 + }, 233 + "compositePrimaryKeys": {}, 234 + "uniqueConstraints": { 235 + "posts_slug_unique": { 236 + "name": "posts_slug_unique", 237 + "nullsNotDistinct": false, 238 + "columns": [ 239 + "slug" 240 + ] 241 + } 242 + }, 243 + "policies": {}, 244 + "checkConstraints": {}, 245 + "isRLSEnabled": false 246 + }, 247 + "public.users": { 248 + "name": "users", 249 + "schema": "", 250 + "columns": { 251 + "id": { 252 + "name": "id", 253 + "type": "bigint", 254 + "primaryKey": true, 255 + "notNull": true 256 + }, 257 + "username": { 258 + "name": "username", 259 + "type": "varchar(32)", 260 + "primaryKey": false, 261 + "notNull": true 262 + }, 263 + "display_name": { 264 + "name": "display_name", 265 + "type": "varchar(64)", 266 + "primaryKey": false, 267 + "notNull": false 268 + }, 269 + "email": { 270 + "name": "email", 271 + "type": "varchar(320)", 272 + "primaryKey": false, 273 + "notNull": true 274 + }, 275 + "password": { 276 + "name": "password", 277 + "type": "varchar(72)", 278 + "primaryKey": false, 279 + "notNull": true 280 + }, 281 + "avatar": { 282 + "name": "avatar", 283 + "type": "varchar(40)", 284 + "primaryKey": false, 285 + "notNull": false 286 + }, 287 + "permissions": { 288 + "name": "permissions", 289 + "type": "integer", 290 + "primaryKey": false, 291 + "notNull": true, 292 + "default": 0 293 + } 294 + }, 295 + "indexes": {}, 296 + "foreignKeys": {}, 297 + "compositePrimaryKeys": {}, 298 + "uniqueConstraints": { 299 + "users_username_unique": { 300 + "name": "users_username_unique", 301 + "nullsNotDistinct": false, 302 + "columns": [ 303 + "username" 304 + ] 305 + }, 306 + "users_email_unique": { 307 + "name": "users_email_unique", 308 + "nullsNotDistinct": false, 309 + "columns": [ 310 + "email" 311 + ] 312 + }, 313 + "users_password_unique": { 314 + "name": "users_password_unique", 315 + "nullsNotDistinct": false, 316 + "columns": [ 317 + "password" 318 + ] 319 + } 320 + }, 321 + "policies": {}, 322 + "checkConstraints": {}, 323 + "isRLSEnabled": false 324 + } 325 + }, 326 + "enums": {}, 327 + "schemas": {}, 328 + "sequences": {}, 329 + "roles": {}, 330 + "policies": {}, 331 + "views": {}, 332 + "_meta": { 333 + "columns": {}, 334 + "schemas": {}, 335 + "tables": {} 336 + } 337 + }
+491
.drizzle/meta/0005_snapshot.json
··· 1 + { 2 + "id": "72d03eee-b691-4a9f-8565-a326009aea37", 3 + "prevId": "7c936126-194c-4f96-b833-ab8bd06b726e", 4 + "version": "7", 5 + "dialect": "postgresql", 6 + "tables": { 7 + "public.comments": { 8 + "name": "comments", 9 + "schema": "", 10 + "columns": { 11 + "id": { 12 + "name": "id", 13 + "type": "bigint", 14 + "primaryKey": true, 15 + "notNull": true 16 + }, 17 + "post_id": { 18 + "name": "post_id", 19 + "type": "bigint", 20 + "primaryKey": false, 21 + "notNull": false 22 + }, 23 + "parent_id": { 24 + "name": "parent_id", 25 + "type": "bigint", 26 + "primaryKey": false, 27 + "notNull": false 28 + }, 29 + "author_id": { 30 + "name": "author_id", 31 + "type": "bigint", 32 + "primaryKey": false, 33 + "notNull": false 34 + }, 35 + "display_name": { 36 + "name": "display_name", 37 + "type": "varchar(64)", 38 + "primaryKey": false, 39 + "notNull": false 40 + }, 41 + "content": { 42 + "name": "content", 43 + "type": "text", 44 + "primaryKey": false, 45 + "notNull": true 46 + } 47 + }, 48 + "indexes": {}, 49 + "foreignKeys": { 50 + "comments_post_id_posts_id_fk": { 51 + "name": "comments_post_id_posts_id_fk", 52 + "tableFrom": "comments", 53 + "tableTo": "posts", 54 + "columnsFrom": [ 55 + "post_id" 56 + ], 57 + "columnsTo": [ 58 + "id" 59 + ], 60 + "onDelete": "cascade", 61 + "onUpdate": "no action" 62 + }, 63 + "comments_parent_id_comments_id_fk": { 64 + "name": "comments_parent_id_comments_id_fk", 65 + "tableFrom": "comments", 66 + "tableTo": "comments", 67 + "columnsFrom": [ 68 + "parent_id" 69 + ], 70 + "columnsTo": [ 71 + "id" 72 + ], 73 + "onDelete": "cascade", 74 + "onUpdate": "no action" 75 + }, 76 + "comments_author_id_users_id_fk": { 77 + "name": "comments_author_id_users_id_fk", 78 + "tableFrom": "comments", 79 + "tableTo": "users", 80 + "columnsFrom": [ 81 + "author_id" 82 + ], 83 + "columnsTo": [ 84 + "id" 85 + ], 86 + "onDelete": "cascade", 87 + "onUpdate": "no action" 88 + } 89 + }, 90 + "compositePrimaryKeys": {}, 91 + "uniqueConstraints": {}, 92 + "policies": {}, 93 + "checkConstraints": {}, 94 + "isRLSEnabled": false 95 + }, 96 + "public.gallery_images": { 97 + "name": "gallery_images", 98 + "schema": "", 99 + "columns": { 100 + "id": { 101 + "name": "id", 102 + "type": "bigint", 103 + "primaryKey": true, 104 + "notNull": true 105 + }, 106 + "art_id": { 107 + "name": "art_id", 108 + "type": "bigint", 109 + "primaryKey": false, 110 + "notNull": false 111 + }, 112 + "hash": { 113 + "name": "hash", 114 + "type": "varchar(40)", 115 + "primaryKey": false, 116 + "notNull": true 117 + }, 118 + "name": { 119 + "name": "name", 120 + "type": "varchar(1024)", 121 + "primaryKey": false, 122 + "notNull": true 123 + }, 124 + "alt": { 125 + "name": "alt", 126 + "type": "text", 127 + "primaryKey": false, 128 + "notNull": true 129 + }, 130 + "main": { 131 + "name": "main", 132 + "type": "boolean", 133 + "primaryKey": false, 134 + "notNull": true, 135 + "default": false 136 + } 137 + }, 138 + "indexes": {}, 139 + "foreignKeys": { 140 + "gallery_images_art_id_gallery_id_fk": { 141 + "name": "gallery_images_art_id_gallery_id_fk", 142 + "tableFrom": "gallery_images", 143 + "tableTo": "gallery", 144 + "columnsFrom": [ 145 + "art_id" 146 + ], 147 + "columnsTo": [ 148 + "id" 149 + ], 150 + "onDelete": "cascade", 151 + "onUpdate": "no action" 152 + } 153 + }, 154 + "compositePrimaryKeys": {}, 155 + "uniqueConstraints": { 156 + "gallery_images_hash_unique": { 157 + "name": "gallery_images_hash_unique", 158 + "nullsNotDistinct": false, 159 + "columns": [ 160 + "hash" 161 + ] 162 + } 163 + }, 164 + "policies": {}, 165 + "checkConstraints": {}, 166 + "isRLSEnabled": false 167 + }, 168 + "public.gallery": { 169 + "name": "gallery", 170 + "schema": "", 171 + "columns": { 172 + "id": { 173 + "name": "id", 174 + "type": "bigint", 175 + "primaryKey": true, 176 + "notNull": true 177 + }, 178 + "type": { 179 + "name": "type", 180 + "type": "gallery_type", 181 + "typeSchema": "public", 182 + "primaryKey": false, 183 + "notNull": true 184 + }, 185 + "slug": { 186 + "name": "slug", 187 + "type": "varchar(128)", 188 + "primaryKey": false, 189 + "notNull": true 190 + }, 191 + "title": { 192 + "name": "title", 193 + "type": "varchar(256)", 194 + "primaryKey": false, 195 + "notNull": true 196 + }, 197 + "content": { 198 + "name": "content", 199 + "type": "text", 200 + "primaryKey": false, 201 + "notNull": true 202 + }, 203 + "draft": { 204 + "name": "draft", 205 + "type": "boolean", 206 + "primaryKey": false, 207 + "notNull": true, 208 + "default": true 209 + }, 210 + "published_at": { 211 + "name": "published_at", 212 + "type": "timestamp", 213 + "primaryKey": false, 214 + "notNull": true, 215 + "default": "now()" 216 + }, 217 + "updated_at": { 218 + "name": "updated_at", 219 + "type": "timestamp", 220 + "primaryKey": false, 221 + "notNull": true, 222 + "default": "now()" 223 + } 224 + }, 225 + "indexes": {}, 226 + "foreignKeys": {}, 227 + "compositePrimaryKeys": {}, 228 + "uniqueConstraints": { 229 + "gallery_slug_unique": { 230 + "name": "gallery_slug_unique", 231 + "nullsNotDistinct": false, 232 + "columns": [ 233 + "slug" 234 + ] 235 + } 236 + }, 237 + "policies": {}, 238 + "checkConstraints": {}, 239 + "isRLSEnabled": false 240 + }, 241 + "public.posts_images": { 242 + "name": "posts_images", 243 + "schema": "", 244 + "columns": { 245 + "id": { 246 + "name": "id", 247 + "type": "bigint", 248 + "primaryKey": true, 249 + "notNull": true 250 + }, 251 + "post_id": { 252 + "name": "post_id", 253 + "type": "bigint", 254 + "primaryKey": false, 255 + "notNull": false 256 + }, 257 + "hash": { 258 + "name": "hash", 259 + "type": "varchar(40)", 260 + "primaryKey": false, 261 + "notNull": true 262 + }, 263 + "name": { 264 + "name": "name", 265 + "type": "varchar(1024)", 266 + "primaryKey": false, 267 + "notNull": true 268 + } 269 + }, 270 + "indexes": {}, 271 + "foreignKeys": { 272 + "posts_images_post_id_posts_id_fk": { 273 + "name": "posts_images_post_id_posts_id_fk", 274 + "tableFrom": "posts_images", 275 + "tableTo": "posts", 276 + "columnsFrom": [ 277 + "post_id" 278 + ], 279 + "columnsTo": [ 280 + "id" 281 + ], 282 + "onDelete": "cascade", 283 + "onUpdate": "no action" 284 + } 285 + }, 286 + "compositePrimaryKeys": {}, 287 + "uniqueConstraints": { 288 + "posts_images_hash_unique": { 289 + "name": "posts_images_hash_unique", 290 + "nullsNotDistinct": false, 291 + "columns": [ 292 + "hash" 293 + ] 294 + } 295 + }, 296 + "policies": {}, 297 + "checkConstraints": {}, 298 + "isRLSEnabled": false 299 + }, 300 + "public.posts": { 301 + "name": "posts", 302 + "schema": "", 303 + "columns": { 304 + "id": { 305 + "name": "id", 306 + "type": "bigint", 307 + "primaryKey": true, 308 + "notNull": true 309 + }, 310 + "author_id": { 311 + "name": "author_id", 312 + "type": "bigint", 313 + "primaryKey": false, 314 + "notNull": false 315 + }, 316 + "slug": { 317 + "name": "slug", 318 + "type": "varchar(128)", 319 + "primaryKey": false, 320 + "notNull": true 321 + }, 322 + "title": { 323 + "name": "title", 324 + "type": "varchar(256)", 325 + "primaryKey": false, 326 + "notNull": true 327 + }, 328 + "excerpt": { 329 + "name": "excerpt", 330 + "type": "text", 331 + "primaryKey": false, 332 + "notNull": true 333 + }, 334 + "content": { 335 + "name": "content", 336 + "type": "text", 337 + "primaryKey": false, 338 + "notNull": true 339 + }, 340 + "draft": { 341 + "name": "draft", 342 + "type": "boolean", 343 + "primaryKey": false, 344 + "notNull": true, 345 + "default": true 346 + }, 347 + "published_at": { 348 + "name": "published_at", 349 + "type": "timestamp", 350 + "primaryKey": false, 351 + "notNull": true, 352 + "default": "now()" 353 + }, 354 + "updated_at": { 355 + "name": "updated_at", 356 + "type": "timestamp", 357 + "primaryKey": false, 358 + "notNull": true, 359 + "default": "now()" 360 + } 361 + }, 362 + "indexes": {}, 363 + "foreignKeys": { 364 + "posts_author_id_users_id_fk": { 365 + "name": "posts_author_id_users_id_fk", 366 + "tableFrom": "posts", 367 + "tableTo": "users", 368 + "columnsFrom": [ 369 + "author_id" 370 + ], 371 + "columnsTo": [ 372 + "id" 373 + ], 374 + "onDelete": "cascade", 375 + "onUpdate": "no action" 376 + } 377 + }, 378 + "compositePrimaryKeys": {}, 379 + "uniqueConstraints": { 380 + "posts_slug_unique": { 381 + "name": "posts_slug_unique", 382 + "nullsNotDistinct": false, 383 + "columns": [ 384 + "slug" 385 + ] 386 + } 387 + }, 388 + "policies": {}, 389 + "checkConstraints": {}, 390 + "isRLSEnabled": false 391 + }, 392 + "public.users": { 393 + "name": "users", 394 + "schema": "", 395 + "columns": { 396 + "id": { 397 + "name": "id", 398 + "type": "bigint", 399 + "primaryKey": true, 400 + "notNull": true 401 + }, 402 + "username": { 403 + "name": "username", 404 + "type": "varchar(32)", 405 + "primaryKey": false, 406 + "notNull": true 407 + }, 408 + "display_name": { 409 + "name": "display_name", 410 + "type": "varchar(64)", 411 + "primaryKey": false, 412 + "notNull": false 413 + }, 414 + "email": { 415 + "name": "email", 416 + "type": "varchar(320)", 417 + "primaryKey": false, 418 + "notNull": true 419 + }, 420 + "password": { 421 + "name": "password", 422 + "type": "varchar(72)", 423 + "primaryKey": false, 424 + "notNull": true 425 + }, 426 + "avatar": { 427 + "name": "avatar", 428 + "type": "varchar(40)", 429 + "primaryKey": false, 430 + "notNull": false 431 + }, 432 + "permissions": { 433 + "name": "permissions", 434 + "type": "integer", 435 + "primaryKey": false, 436 + "notNull": true, 437 + "default": 0 438 + } 439 + }, 440 + "indexes": {}, 441 + "foreignKeys": {}, 442 + "compositePrimaryKeys": {}, 443 + "uniqueConstraints": { 444 + "users_username_unique": { 445 + "name": "users_username_unique", 446 + "nullsNotDistinct": false, 447 + "columns": [ 448 + "username" 449 + ] 450 + }, 451 + "users_email_unique": { 452 + "name": "users_email_unique", 453 + "nullsNotDistinct": false, 454 + "columns": [ 455 + "email" 456 + ] 457 + }, 458 + "users_password_unique": { 459 + "name": "users_password_unique", 460 + "nullsNotDistinct": false, 461 + "columns": [ 462 + "password" 463 + ] 464 + } 465 + }, 466 + "policies": {}, 467 + "checkConstraints": {}, 468 + "isRLSEnabled": false 469 + } 470 + }, 471 + "enums": { 472 + "public.gallery_type": { 473 + "name": "gallery_type", 474 + "schema": "public", 475 + "values": [ 476 + "art", 477 + "picture" 478 + ] 479 + } 480 + }, 481 + "schemas": {}, 482 + "sequences": {}, 483 + "roles": {}, 484 + "policies": {}, 485 + "views": {}, 486 + "_meta": { 487 + "columns": {}, 488 + "schemas": {}, 489 + "tables": {} 490 + } 491 + }
+14
.drizzle/meta/_journal.json
··· 29 29 "when": 1774713093687, 30 30 "tag": "0003_perfect_chimera", 31 31 "breakpoints": true 32 + }, 33 + { 34 + "idx": 4, 35 + "version": "7", 36 + "when": 1774792923800, 37 + "tag": "0004_previous_gideon", 38 + "breakpoints": true 39 + }, 40 + { 41 + "idx": 5, 42 + "version": "7", 43 + "when": 1774793488631, 44 + "tag": "0005_slow_songbird", 45 + "breakpoints": true 32 46 } 33 47 ] 34 48 }
+20 -1
.drizzle/relations.ts
··· 1 1 import { relations } from "drizzle-orm/relations"; 2 - import { posts, comments, users } from "./schema"; 2 + import { posts, comments, users, postsImages, gallery, galleryImages } from "./schema"; 3 3 4 4 export const commentsRelations = relations(comments, ({one, many}) => ({ 5 5 post: one(posts, { ··· 26 26 fields: [posts.authorId], 27 27 references: [users.id] 28 28 }), 29 + postsImages: many(postsImages), 29 30 })); 30 31 31 32 export const usersRelations = relations(users, ({many}) => ({ 32 33 comments: many(comments), 33 34 posts: many(posts), 35 + })); 36 + 37 + export const postsImagesRelations = relations(postsImages, ({one}) => ({ 38 + post: one(posts, { 39 + fields: [postsImages.postId], 40 + references: [posts.id] 41 + }), 42 + })); 43 + 44 + export const galleryImagesRelations = relations(galleryImages, ({one}) => ({ 45 + gallery: one(gallery, { 46 + fields: [galleryImages.artId], 47 + references: [gallery.id] 48 + }), 49 + })); 50 + 51 + export const galleryRelations = relations(gallery, ({many}) => ({ 52 + galleryImages: many(galleryImages), 34 53 }));
+50 -1
.drizzle/schema.ts
··· 1 - import { pgTable, foreignKey, bigint, varchar, text, unique, integer, timestamp, boolean } from "drizzle-orm/pg-core" 1 + import { pgTable, foreignKey, bigint, varchar, text, unique, integer, timestamp, boolean, pgEnum } from "drizzle-orm/pg-core" 2 2 import { sql } from "drizzle-orm" 3 3 4 + export const galleryType = pgEnum("gallery_type", ['art', 'picture']) 4 5 5 6 6 7 export const comments = pgTable("comments", { ··· 67 68 }).onDelete("cascade"), 68 69 unique("posts_slug_unique").on(table.slug), 69 70 ]); 71 + 72 + export const postsImages = pgTable("posts_images", { 73 + // You can use { mode: "bigint" } if numbers are exceeding js number limitations 74 + id: bigint({ mode: "number" }).primaryKey().notNull(), 75 + // You can use { mode: "bigint" } if numbers are exceeding js number limitations 76 + postId: bigint("post_id", { mode: "number" }), 77 + hash: varchar({ length: 40 }).notNull(), 78 + name: varchar({ length: 1024 }).notNull(), 79 + }, (table) => [ 80 + foreignKey({ 81 + columns: [table.postId], 82 + foreignColumns: [posts.id], 83 + name: "posts_images_post_id_posts_id_fk" 84 + }).onDelete("cascade"), 85 + unique("posts_images_hash_unique").on(table.hash), 86 + ]); 87 + 88 + export const gallery = pgTable("gallery", { 89 + // You can use { mode: "bigint" } if numbers are exceeding js number limitations 90 + id: bigint({ mode: "number" }).primaryKey().notNull(), 91 + type: galleryType().notNull(), 92 + slug: varchar({ length: 128 }).notNull(), 93 + title: varchar({ length: 256 }).notNull(), 94 + content: text().notNull(), 95 + draft: boolean().default(true).notNull(), 96 + publishedAt: timestamp("published_at", { mode: 'string' }).defaultNow().notNull(), 97 + updatedAt: timestamp("updated_at", { mode: 'string' }).defaultNow().notNull(), 98 + }, (table) => [ 99 + unique("gallery_slug_unique").on(table.slug), 100 + ]); 101 + 102 + export const galleryImages = pgTable("gallery_images", { 103 + // You can use { mode: "bigint" } if numbers are exceeding js number limitations 104 + id: bigint({ mode: "number" }).primaryKey().notNull(), 105 + // You can use { mode: "bigint" } if numbers are exceeding js number limitations 106 + artId: bigint("art_id", { mode: "number" }), 107 + hash: varchar({ length: 40 }).notNull(), 108 + name: varchar({ length: 1024 }).notNull(), 109 + alt: text().notNull(), 110 + main: boolean().default(false).notNull(), 111 + }, (table) => [ 112 + foreignKey({ 113 + columns: [table.artId], 114 + foreignColumns: [gallery.id], 115 + name: "gallery_images_art_id_gallery_id_fk" 116 + }).onDelete("cascade"), 117 + unique("gallery_images_hash_unique").on(table.hash), 118 + ]);
+58 -3
lib/db/schema.ts
··· 1 1 import { 2 2 boolean, 3 3 integer, 4 + pgEnum, 4 5 pgTable, 5 6 text, 6 7 timestamp, ··· 10 11 import { snowflake } from '@/lib/db/types/snowflake'; 11 12 import { snowflakeGenerator } from '@/lib/snowflake'; 12 13 14 + // Enums 15 + export const galleryEnum = pgEnum('gallery_type', ['art', 'picture']); 16 + 17 + // User 13 18 export const usersTable = pgTable('users', { 14 19 id: snowflake() 15 20 .primaryKey() ··· 26 31 permissions: integer().default(0).notNull() 27 32 }); 28 33 34 + // Blog 29 35 export const postsTable = pgTable('posts', { 30 36 id: snowflake() 31 37 .primaryKey() ··· 43 49 44 50 draft: boolean().default(true).notNull(), 45 51 46 - publishedAt: timestamp() 47 - .notNull() 48 - .defaultNow(), 52 + publishedAt: timestamp().notNull().defaultNow(), 49 53 updatedAt: timestamp() 50 54 .notNull() 51 55 .defaultNow() 52 56 .$onUpdate(() => new Date()) 53 57 }); 54 58 59 + export const postsImagesTable = pgTable('posts_images', { 60 + id: snowflake() 61 + .primaryKey() 62 + .$defaultFn(() => snowflakeGenerator.nextId()), 63 + 64 + post: snowflake('post_id').references(() => postsTable.id, { 65 + onDelete: 'cascade' 66 + }), 67 + 68 + hash: varchar({ length: 40 }).unique().notNull(), 69 + name: varchar({ length: 1024 }).notNull() 70 + }); 71 + 55 72 export const commentsTable = pgTable('comments', { 56 73 id: snowflake() 57 74 .primaryKey() ··· 72 89 73 90 content: text().notNull() 74 91 }); 92 + 93 + // Art & Photos 94 + export const galleryTable = pgTable('gallery', { 95 + id: snowflake() 96 + .primaryKey() 97 + .$defaultFn(() => snowflakeGenerator.nextId()), 98 + 99 + type: galleryEnum().notNull(), 100 + 101 + slug: varchar({ length: 128 }).unique().notNull(), 102 + title: varchar({ length: 256 }).notNull(), 103 + 104 + content: text().notNull(), 105 + 106 + draft: boolean().default(true).notNull(), 107 + 108 + publishedAt: timestamp().notNull().defaultNow(), 109 + updatedAt: timestamp() 110 + .notNull() 111 + .defaultNow() 112 + .$onUpdate(() => new Date()) 113 + }); 114 + 115 + export const galleryImagesTable = pgTable('gallery_images', { 116 + id: snowflake() 117 + .primaryKey() 118 + .$defaultFn(() => snowflakeGenerator.nextId()), 119 + 120 + post: snowflake('art_id').references(() => galleryTable.id, { 121 + onDelete: 'cascade' 122 + }), 123 + 124 + hash: varchar({ length: 40 }).unique().notNull(), 125 + name: varchar({ length: 1024 }).notNull(), 126 + 127 + alt: text().notNull(), 128 + main: boolean().default(false).notNull() 129 + });