fix(db): make databases.agent_id and agent_database_id nullable for soft-delete

This commit is contained in:
charles-gauthereau
2026-07-05 18:11:32 +02:00
parent 693ef6ec3e
commit 6b89cdfa1d
5 changed files with 2991 additions and 3 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ export const DatabaseCard = (props: DatabaseCardProps) => {
const handleCopy = (e: React.MouseEvent) => {
e.preventDefault();
e.stopPropagation();
navigator.clipboard.writeText(database.agentDatabaseId);
navigator.clipboard.writeText(database.agentDatabaseId ?? "");
setIsCopied(true);
setTimeout(() => setIsCopied(false), 2000);
};
@@ -0,0 +1,2 @@
ALTER TABLE "databases" ALTER COLUMN "agent_database_id" DROP NOT NULL;--> statement-breakpoint
ALTER TABLE "databases" ALTER COLUMN "agent_id" DROP NOT NULL;
File diff suppressed because it is too large Load Diff
+7
View File
@@ -491,6 +491,13 @@
"when": 1782937885439,
"tag": "0069_worried_alex_wilder",
"breakpoints": true
},
{
"idx": 70,
"version": "7",
"when": 1783264084846,
"tag": "0070_illegal_joseph",
"breakpoints": true
}
]
}
+1 -2
View File
@@ -13,7 +13,7 @@ import {JobLog, jobLog} from "@/db/schema/17_job-log";
export const database = pgTable("databases", {
id: uuid("id").primaryKey().defaultRandom(),
agentDatabaseId: uuid("agent_database_id").notNull().defaultRandom(),
agentDatabaseId: uuid("agent_database_id").defaultRandom(),
name: text("name").notNull(),
dbms: dbmsEnum("dbms").notNull(),
description: text("description"),
@@ -22,7 +22,6 @@ export const database = pgTable("databases", {
backupToRestore: text("backup_to_restore"),
healthErrorCount: integer("health_error_count"),
agentId: uuid("agent_id")
.notNull()
.references(() => agent.id, {onDelete: "cascade"}),
lastContact: timestamp("last_contact"),
projectId: uuid("project_id")