chore: 生成初始 Drizzle 迁移和路由树

This commit is contained in:
2026-03-30 21:28:57 +08:00
parent 3ce981a06a
commit 8c3425359d
3 changed files with 1065 additions and 15 deletions
@@ -0,0 +1,75 @@
CREATE TABLE "bookmark" (
"id" uuid PRIMARY KEY,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
"name" text NOT NULL,
"url" text NOT NULL,
"icon" text,
"category_id" uuid NOT NULL,
"is_public" boolean DEFAULT true NOT NULL,
"order_id" integer DEFAULT 0 NOT NULL,
"user_id" text NOT NULL
);
--> statement-breakpoint
CREATE TABLE "category" (
"id" uuid PRIMARY KEY,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
"name" text NOT NULL,
"is_pinned" boolean DEFAULT false NOT NULL,
"is_public" boolean DEFAULT true NOT NULL,
"order_id" integer DEFAULT 0 NOT NULL,
"user_id" text NOT NULL
);
--> statement-breakpoint
CREATE TABLE "account" (
"id" text PRIMARY KEY,
"account_id" text NOT NULL,
"provider_id" text NOT NULL,
"user_id" text NOT NULL,
"access_token" text,
"refresh_token" text,
"id_token" text,
"access_token_expires_at" timestamp with time zone,
"refresh_token_expires_at" timestamp with time zone,
"scope" text,
"password" text,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "session" (
"id" text PRIMARY KEY,
"expires_at" timestamp with time zone NOT NULL,
"token" text NOT NULL UNIQUE,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
"ip_address" text,
"user_agent" text,
"user_id" text NOT NULL
);
--> statement-breakpoint
CREATE TABLE "user" (
"id" text PRIMARY KEY,
"name" text NOT NULL,
"email" text NOT NULL UNIQUE,
"email_verified" boolean DEFAULT false NOT NULL,
"image" text,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "verification" (
"id" text PRIMARY KEY,
"identifier" text NOT NULL,
"value" text NOT NULL,
"expires_at" timestamp with time zone NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "bookmark" ADD CONSTRAINT "bookmark_category_id_category_id_fkey" FOREIGN KEY ("category_id") REFERENCES "category"("id") ON DELETE CASCADE;--> statement-breakpoint
ALTER TABLE "bookmark" ADD CONSTRAINT "bookmark_user_id_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE CASCADE;--> statement-breakpoint
ALTER TABLE "category" ADD CONSTRAINT "category_user_id_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE CASCADE;--> statement-breakpoint
ALTER TABLE "account" ADD CONSTRAINT "account_user_id_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE CASCADE;--> statement-breakpoint
ALTER TABLE "session" ADD CONSTRAINT "session_user_id_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE CASCADE;
@@ -0,0 +1,852 @@
{
"version": "8",
"dialect": "postgres",
"id": "1521f139-4e9c-4d3f-965b-c9cbe21f80ff",
"prevIds": ["00000000-0000-0000-0000-000000000000"],
"ddl": [
{
"isRlsEnabled": false,
"name": "bookmark",
"entityType": "tables",
"schema": "public"
},
{
"isRlsEnabled": false,
"name": "category",
"entityType": "tables",
"schema": "public"
},
{
"isRlsEnabled": false,
"name": "account",
"entityType": "tables",
"schema": "public"
},
{
"isRlsEnabled": false,
"name": "session",
"entityType": "tables",
"schema": "public"
},
{
"isRlsEnabled": false,
"name": "user",
"entityType": "tables",
"schema": "public"
},
{
"isRlsEnabled": false,
"name": "verification",
"entityType": "tables",
"schema": "public"
},
{
"type": "uuid",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "id",
"entityType": "columns",
"schema": "public",
"table": "bookmark"
},
{
"type": "timestamp with time zone",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": "now()",
"generated": null,
"identity": null,
"name": "created_at",
"entityType": "columns",
"schema": "public",
"table": "bookmark"
},
{
"type": "timestamp with time zone",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": "now()",
"generated": null,
"identity": null,
"name": "updated_at",
"entityType": "columns",
"schema": "public",
"table": "bookmark"
},
{
"type": "text",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "name",
"entityType": "columns",
"schema": "public",
"table": "bookmark"
},
{
"type": "text",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "url",
"entityType": "columns",
"schema": "public",
"table": "bookmark"
},
{
"type": "text",
"typeSchema": null,
"notNull": false,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "icon",
"entityType": "columns",
"schema": "public",
"table": "bookmark"
},
{
"type": "uuid",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "category_id",
"entityType": "columns",
"schema": "public",
"table": "bookmark"
},
{
"type": "boolean",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": "true",
"generated": null,
"identity": null,
"name": "is_public",
"entityType": "columns",
"schema": "public",
"table": "bookmark"
},
{
"type": "integer",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": "0",
"generated": null,
"identity": null,
"name": "order_id",
"entityType": "columns",
"schema": "public",
"table": "bookmark"
},
{
"type": "text",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "user_id",
"entityType": "columns",
"schema": "public",
"table": "bookmark"
},
{
"type": "uuid",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "id",
"entityType": "columns",
"schema": "public",
"table": "category"
},
{
"type": "timestamp with time zone",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": "now()",
"generated": null,
"identity": null,
"name": "created_at",
"entityType": "columns",
"schema": "public",
"table": "category"
},
{
"type": "timestamp with time zone",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": "now()",
"generated": null,
"identity": null,
"name": "updated_at",
"entityType": "columns",
"schema": "public",
"table": "category"
},
{
"type": "text",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "name",
"entityType": "columns",
"schema": "public",
"table": "category"
},
{
"type": "boolean",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": "false",
"generated": null,
"identity": null,
"name": "is_pinned",
"entityType": "columns",
"schema": "public",
"table": "category"
},
{
"type": "boolean",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": "true",
"generated": null,
"identity": null,
"name": "is_public",
"entityType": "columns",
"schema": "public",
"table": "category"
},
{
"type": "integer",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": "0",
"generated": null,
"identity": null,
"name": "order_id",
"entityType": "columns",
"schema": "public",
"table": "category"
},
{
"type": "text",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "user_id",
"entityType": "columns",
"schema": "public",
"table": "category"
},
{
"type": "text",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "id",
"entityType": "columns",
"schema": "public",
"table": "account"
},
{
"type": "text",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "account_id",
"entityType": "columns",
"schema": "public",
"table": "account"
},
{
"type": "text",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "provider_id",
"entityType": "columns",
"schema": "public",
"table": "account"
},
{
"type": "text",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "user_id",
"entityType": "columns",
"schema": "public",
"table": "account"
},
{
"type": "text",
"typeSchema": null,
"notNull": false,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "access_token",
"entityType": "columns",
"schema": "public",
"table": "account"
},
{
"type": "text",
"typeSchema": null,
"notNull": false,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "refresh_token",
"entityType": "columns",
"schema": "public",
"table": "account"
},
{
"type": "text",
"typeSchema": null,
"notNull": false,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "id_token",
"entityType": "columns",
"schema": "public",
"table": "account"
},
{
"type": "timestamp with time zone",
"typeSchema": null,
"notNull": false,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "access_token_expires_at",
"entityType": "columns",
"schema": "public",
"table": "account"
},
{
"type": "timestamp with time zone",
"typeSchema": null,
"notNull": false,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "refresh_token_expires_at",
"entityType": "columns",
"schema": "public",
"table": "account"
},
{
"type": "text",
"typeSchema": null,
"notNull": false,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "scope",
"entityType": "columns",
"schema": "public",
"table": "account"
},
{
"type": "text",
"typeSchema": null,
"notNull": false,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "password",
"entityType": "columns",
"schema": "public",
"table": "account"
},
{
"type": "timestamp with time zone",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": "now()",
"generated": null,
"identity": null,
"name": "created_at",
"entityType": "columns",
"schema": "public",
"table": "account"
},
{
"type": "timestamp with time zone",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": "now()",
"generated": null,
"identity": null,
"name": "updated_at",
"entityType": "columns",
"schema": "public",
"table": "account"
},
{
"type": "text",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "id",
"entityType": "columns",
"schema": "public",
"table": "session"
},
{
"type": "timestamp with time zone",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "expires_at",
"entityType": "columns",
"schema": "public",
"table": "session"
},
{
"type": "text",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "token",
"entityType": "columns",
"schema": "public",
"table": "session"
},
{
"type": "timestamp with time zone",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": "now()",
"generated": null,
"identity": null,
"name": "created_at",
"entityType": "columns",
"schema": "public",
"table": "session"
},
{
"type": "timestamp with time zone",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": "now()",
"generated": null,
"identity": null,
"name": "updated_at",
"entityType": "columns",
"schema": "public",
"table": "session"
},
{
"type": "text",
"typeSchema": null,
"notNull": false,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "ip_address",
"entityType": "columns",
"schema": "public",
"table": "session"
},
{
"type": "text",
"typeSchema": null,
"notNull": false,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "user_agent",
"entityType": "columns",
"schema": "public",
"table": "session"
},
{
"type": "text",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "user_id",
"entityType": "columns",
"schema": "public",
"table": "session"
},
{
"type": "text",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "id",
"entityType": "columns",
"schema": "public",
"table": "user"
},
{
"type": "text",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "name",
"entityType": "columns",
"schema": "public",
"table": "user"
},
{
"type": "text",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "email",
"entityType": "columns",
"schema": "public",
"table": "user"
},
{
"type": "boolean",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": "false",
"generated": null,
"identity": null,
"name": "email_verified",
"entityType": "columns",
"schema": "public",
"table": "user"
},
{
"type": "text",
"typeSchema": null,
"notNull": false,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "image",
"entityType": "columns",
"schema": "public",
"table": "user"
},
{
"type": "timestamp with time zone",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": "now()",
"generated": null,
"identity": null,
"name": "created_at",
"entityType": "columns",
"schema": "public",
"table": "user"
},
{
"type": "timestamp with time zone",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": "now()",
"generated": null,
"identity": null,
"name": "updated_at",
"entityType": "columns",
"schema": "public",
"table": "user"
},
{
"type": "text",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "id",
"entityType": "columns",
"schema": "public",
"table": "verification"
},
{
"type": "text",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "identifier",
"entityType": "columns",
"schema": "public",
"table": "verification"
},
{
"type": "text",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "value",
"entityType": "columns",
"schema": "public",
"table": "verification"
},
{
"type": "timestamp with time zone",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "expires_at",
"entityType": "columns",
"schema": "public",
"table": "verification"
},
{
"type": "timestamp with time zone",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": "now()",
"generated": null,
"identity": null,
"name": "created_at",
"entityType": "columns",
"schema": "public",
"table": "verification"
},
{
"type": "timestamp with time zone",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": "now()",
"generated": null,
"identity": null,
"name": "updated_at",
"entityType": "columns",
"schema": "public",
"table": "verification"
},
{
"nameExplicit": false,
"columns": ["category_id"],
"schemaTo": "public",
"tableTo": "category",
"columnsTo": ["id"],
"onUpdate": "NO ACTION",
"onDelete": "CASCADE",
"name": "bookmark_category_id_category_id_fkey",
"entityType": "fks",
"schema": "public",
"table": "bookmark"
},
{
"nameExplicit": false,
"columns": ["user_id"],
"schemaTo": "public",
"tableTo": "user",
"columnsTo": ["id"],
"onUpdate": "NO ACTION",
"onDelete": "CASCADE",
"name": "bookmark_user_id_user_id_fkey",
"entityType": "fks",
"schema": "public",
"table": "bookmark"
},
{
"nameExplicit": false,
"columns": ["user_id"],
"schemaTo": "public",
"tableTo": "user",
"columnsTo": ["id"],
"onUpdate": "NO ACTION",
"onDelete": "CASCADE",
"name": "category_user_id_user_id_fkey",
"entityType": "fks",
"schema": "public",
"table": "category"
},
{
"nameExplicit": false,
"columns": ["user_id"],
"schemaTo": "public",
"tableTo": "user",
"columnsTo": ["id"],
"onUpdate": "NO ACTION",
"onDelete": "CASCADE",
"name": "account_user_id_user_id_fkey",
"entityType": "fks",
"schema": "public",
"table": "account"
},
{
"nameExplicit": false,
"columns": ["user_id"],
"schemaTo": "public",
"tableTo": "user",
"columnsTo": ["id"],
"onUpdate": "NO ACTION",
"onDelete": "CASCADE",
"name": "session_user_id_user_id_fkey",
"entityType": "fks",
"schema": "public",
"table": "session"
},
{
"columns": ["id"],
"nameExplicit": false,
"name": "bookmark_pkey",
"schema": "public",
"table": "bookmark",
"entityType": "pks"
},
{
"columns": ["id"],
"nameExplicit": false,
"name": "category_pkey",
"schema": "public",
"table": "category",
"entityType": "pks"
},
{
"columns": ["id"],
"nameExplicit": false,
"name": "account_pkey",
"schema": "public",
"table": "account",
"entityType": "pks"
},
{
"columns": ["id"],
"nameExplicit": false,
"name": "session_pkey",
"schema": "public",
"table": "session",
"entityType": "pks"
},
{
"columns": ["id"],
"nameExplicit": false,
"name": "user_pkey",
"schema": "public",
"table": "user",
"entityType": "pks"
},
{
"columns": ["id"],
"nameExplicit": false,
"name": "verification_pkey",
"schema": "public",
"table": "verification",
"entityType": "pks"
},
{
"nameExplicit": false,
"columns": ["token"],
"nullsNotDistinct": false,
"name": "session_token_key",
"schema": "public",
"table": "session",
"entityType": "uniques"
},
{
"nameExplicit": false,
"columns": ["email"],
"nullsNotDistinct": false,
"name": "user_email_key",
"schema": "public",
"table": "user",
"entityType": "uniques"
}
],
"renames": []
}