fix : db cook [no ci]

This commit is contained in:
2026-09-27 17:07:51 +07:00 Unverified
parent 188cec9bda
commit cb09f1af3e
5 changed files with 3050 additions and 37 deletions
+13 -7
View File
@@ -1,11 +1,17 @@
CREATE TABLE "audit_log" (
"id" bigint PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "audit_log_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1),
"author_id" text,
"author" text,
"text" text NOT NULL,
"details" jsonb DEFAULT '{}'::jsonb,
"time" timestamp with time zone DEFAULT now() NOT NULL
"actor_id" text NOT NULL,
"actor_label" text NOT NULL,
"action" varchar(64) NOT NULL,
"target_type" varchar(32) NOT NULL,
"target_id" text NOT NULL,
"scope" varchar(64),
"resulting_version" integer,
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE INDEX "audit_log_time_idx" ON "audit_log" USING btree ("time","id");--> statement-breakpoint
CREATE INDEX "audit_log_author_time_idx" ON "audit_log" USING btree ("author_id","time");
CREATE INDEX "audit_log_created_idx" ON "audit_log" USING btree ("created_at","id");--> statement-breakpoint
CREATE INDEX "audit_log_actor_created_idx" ON "audit_log" USING btree ("actor_id","created_at");--> statement-breakpoint
CREATE INDEX "audit_log_target_created_idx" ON "audit_log" USING btree ("target_type","target_id","created_at");--> statement-breakpoint
CREATE INDEX "audit_log_action_created_idx" ON "audit_log" USING btree ("action","created_at");
+25
View File
@@ -0,0 +1,25 @@
ALTER TABLE "audit_log" RENAME COLUMN "actor_id" TO "author_id";--> statement-breakpoint
ALTER TABLE "audit_log" RENAME COLUMN "actor_label" TO "author";--> statement-breakpoint
ALTER TABLE "audit_log" RENAME COLUMN "action" TO "text";--> statement-breakpoint
ALTER TABLE "audit_log" RENAME COLUMN "metadata" TO "details";--> statement-breakpoint
ALTER TABLE "audit_log" RENAME COLUMN "created_at" TO "time";--> statement-breakpoint
UPDATE "audit_log"
SET "details" = coalesce("details", '{}'::jsonb) || jsonb_strip_nulls(jsonb_build_object(
'target', jsonb_build_object('type', "target_type", 'id', "target_id"),
'scope', "scope",
'version', "resulting_version"
));--> statement-breakpoint
ALTER TABLE "audit_log" ALTER COLUMN "author_id" DROP NOT NULL;--> statement-breakpoint
ALTER TABLE "audit_log" ALTER COLUMN "author" DROP NOT NULL;--> statement-breakpoint
ALTER TABLE "audit_log" ALTER COLUMN "text" TYPE text;--> statement-breakpoint
ALTER TABLE "audit_log" ALTER COLUMN "details" DROP NOT NULL;--> statement-breakpoint
DROP INDEX "audit_log_created_idx";--> statement-breakpoint
DROP INDEX "audit_log_actor_created_idx";--> statement-breakpoint
DROP INDEX "audit_log_target_created_idx";--> statement-breakpoint
DROP INDEX "audit_log_action_created_idx";--> statement-breakpoint
CREATE INDEX "audit_log_time_idx" ON "audit_log" USING btree ("time","id");--> statement-breakpoint
CREATE INDEX "audit_log_author_time_idx" ON "audit_log" USING btree ("author_id","time");--> statement-breakpoint
ALTER TABLE "audit_log" DROP COLUMN "target_type";--> statement-breakpoint
ALTER TABLE "audit_log" DROP COLUMN "target_id";--> statement-breakpoint
ALTER TABLE "audit_log" DROP COLUMN "scope";--> statement-breakpoint
ALTER TABLE "audit_log" DROP COLUMN "resulting_version";
+100 -28
View File
@@ -1,5 +1,5 @@
{
"id": "74274cf2-88e8-40cf-84db-3333cecc34cf",
"id": "cdfff9d0-72b6-44bc-9af7-79b7995f9d49",
"prevId": "06235585-b969-474c-8f40-ba3a55869d1d",
"version": "7",
"dialect": "postgresql",
@@ -538,33 +538,57 @@
"cycle": false
}
},
"author_id": {
"name": "author_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
"author": {
"name": "author",
"type": "text",
"primaryKey": false,
"notNull": false
},
"text": {
"name": "text",
"actor_id": {
"name": "actor_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
"details": {
"name": "details",
"actor_label": {
"name": "actor_label",
"type": "text",
"primaryKey": false,
"notNull": true
},
"action": {
"name": "action",
"type": "varchar(64)",
"primaryKey": false,
"notNull": true
},
"target_type": {
"name": "target_type",
"type": "varchar(32)",
"primaryKey": false,
"notNull": true
},
"target_id": {
"name": "target_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
"scope": {
"name": "scope",
"type": "varchar(64)",
"primaryKey": false,
"notNull": false
},
"resulting_version": {
"name": "resulting_version",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"metadata": {
"name": "metadata",
"type": "jsonb",
"primaryKey": false,
"notNull": false,
"notNull": true,
"default": "'{}'::jsonb"
},
"time": {
"name": "time",
"created_at": {
"name": "created_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
@@ -572,11 +596,11 @@
}
},
"indexes": {
"audit_log_time_idx": {
"name": "audit_log_time_idx",
"audit_log_created_idx": {
"name": "audit_log_created_idx",
"columns": [
{
"expression": "time",
"expression": "created_at",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -593,17 +617,65 @@
"method": "btree",
"with": {}
},
"audit_log_author_time_idx": {
"name": "audit_log_author_time_idx",
"audit_log_actor_created_idx": {
"name": "audit_log_actor_created_idx",
"columns": [
{
"expression": "author_id",
"expression": "actor_id",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
"expression": "time",
"expression": "created_at",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"audit_log_target_created_idx": {
"name": "audit_log_target_created_idx",
"columns": [
{
"expression": "target_type",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
"expression": "target_id",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
"expression": "created_at",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"audit_log_action_created_idx": {
"name": "audit_log_action_created_idx",
"columns": [
{
"expression": "action",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
"expression": "created_at",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -2900,4 +2972,4 @@
"schemas": {},
"tables": {}
}
}
}
File diff suppressed because it is too large Load Diff
+9 -2
View File
@@ -376,9 +376,16 @@
{
"idx": 53,
"version": "7",
"when": 1790503002505,
"when": 1790499026606,
"tag": "0053_woozy_callisto",
"breakpoints": true
},
{
"idx": 54,
"version": "7",
"when": 1790503406247,
"tag": "0054_open_changeling",
"breakpoints": true
}
]
}
}