mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-28 13:39:28 +07:00
🐛 fix: fix db migration snapshot not align with db schema (#10399)
* fix db sql * clean
This commit is contained in:
@@ -187,6 +187,7 @@ table documents {
|
||||
user_id text [not null]
|
||||
client_id text
|
||||
editor_data jsonb
|
||||
slug varchar(255)
|
||||
accessed_at "timestamp with time zone" [not null, default: `now()`]
|
||||
created_at "timestamp with time zone" [not null, default: `now()`]
|
||||
updated_at "timestamp with time zone" [not null, default: `now()`]
|
||||
@@ -197,6 +198,7 @@ table documents {
|
||||
file_id [name: 'documents_file_id_idx']
|
||||
parent_id [name: 'documents_parent_id_idx']
|
||||
(client_id, user_id) [name: 'documents_client_id_user_id_unique', unique]
|
||||
(slug, user_id) [name: 'documents_slug_user_id_unique', unique]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +216,6 @@ table files {
|
||||
metadata jsonb
|
||||
chunk_task_id uuid
|
||||
embedding_task_id uuid
|
||||
slug text [unique]
|
||||
accessed_at "timestamp with time zone" [not null, default: `now()`]
|
||||
created_at "timestamp with time zone" [not null, default: `now()`]
|
||||
updated_at "timestamp with time zone" [not null, default: `now()`]
|
||||
|
||||
@@ -1,6 +1,2 @@
|
||||
ALTER TABLE "documents" ADD COLUMN IF NOT EXISTS "slug" varchar(255);--> statement-breakpoint
|
||||
DO $$ BEGIN
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS "documents_slug_user_id_unique" ON "documents" ("slug","user_id") WHERE "slug" IS NOT NULL;
|
||||
EXCEPTION
|
||||
WHEN duplicate_object THEN null;
|
||||
END $$;
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS "documents_slug_user_id_unique" ON "documents" USING btree ("slug","user_id") WHERE "documents"."slug" is not null;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
},
|
||||
"dialect": "postgresql",
|
||||
"enums": {},
|
||||
"id": "8a423b68-c609-44e1-bd48-f2ed62fec5ef",
|
||||
"id": "20a4c30c-04f0-4993-b493-0ae6a3144f9e",
|
||||
"policies": {},
|
||||
"prevId": "abe0cb47-a970-4ec0-a29f-1afa9bd2fe02",
|
||||
"roles": {},
|
||||
@@ -1259,6 +1259,12 @@
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"slug": {
|
||||
"name": "slug",
|
||||
"type": "varchar(255)",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"accessed_at": {
|
||||
"name": "accessed_at",
|
||||
"type": "timestamp with time zone",
|
||||
@@ -1362,6 +1368,28 @@
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
},
|
||||
"documents_slug_user_id_unique": {
|
||||
"name": "documents_slug_user_id_unique",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "slug",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
},
|
||||
{
|
||||
"expression": "user_id",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
}
|
||||
],
|
||||
"isUnique": true,
|
||||
"where": "\"documents\".\"slug\" is not null",
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
}
|
||||
},
|
||||
"foreignKeys": {
|
||||
@@ -1481,12 +1509,6 @@
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"slug": {
|
||||
"name": "slug",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"accessed_at": {
|
||||
"name": "accessed_at",
|
||||
"type": "timestamp with time zone",
|
||||
@@ -1610,13 +1632,7 @@
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {
|
||||
"files_slug_unique": {
|
||||
"name": "files_slug_unique",
|
||||
"nullsNotDistinct": false,
|
||||
"columns": ["slug"]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
|
||||
@@ -333,7 +333,7 @@
|
||||
{
|
||||
"idx": 47,
|
||||
"version": "7",
|
||||
"when": 1763535087148,
|
||||
"when": 1763987922211,
|
||||
"tag": "0047_add_slug_document",
|
||||
"breakpoints": true
|
||||
}
|
||||
|
||||
@@ -792,10 +792,10 @@
|
||||
{
|
||||
"sql": [
|
||||
"ALTER TABLE \"documents\" ADD COLUMN IF NOT EXISTS \"slug\" varchar(255);",
|
||||
"\nDO $$ BEGIN\n CREATE UNIQUE INDEX IF NOT EXISTS \"documents_slug_user_id_unique\" ON \"documents\" (\"slug\",\"user_id\") WHERE \"slug\" IS NOT NULL;\nEXCEPTION\n WHEN duplicate_object THEN null;\nEND $$;"
|
||||
"\nCREATE UNIQUE INDEX IF NOT EXISTS \"documents_slug_user_id_unique\" ON \"documents\" USING btree (\"slug\",\"user_id\") WHERE \"documents\".\"slug\" is not null;\n"
|
||||
],
|
||||
"bps": true,
|
||||
"folderMillis": 1763535087148,
|
||||
"hash": "57a82ce14d96ffa9f140ff63f00af994e91a74703f4d2378286e36be259f117b"
|
||||
"folderMillis": 1763987922211,
|
||||
"hash": "f823b521f4d25e5dc5ab238b372727d2d2d7f0aed27b5eabc8a9608ce4e50568"
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user