Skip to content

Commit 6e40325

Browse files
committed
🐛 fix issue deleting connections
1 parent b06854a commit 6e40325

File tree

4 files changed

+38
-5
lines changed

4 files changed

+38
-5
lines changed

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
},
66
"scripts": {
77
"dev": "yarn run build && node ./bin/run.js",
8-
"build": "shx rm -rf dist && tsc -b",
8+
"build": "tsc -b",
99
"lint": "eslint . --ext .ts",
10-
"postpack": "shx rm -f oclif.manifest.json",
1110
"posttest": "yarn lint",
1211
"prepack": "yarn build && oclif manifest && yarn run docs",
1312
"prepare": "yarn build",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
Warnings:
3+
4+
- You are about to drop the column `editable` on the `Connection` table. All the data in the column will be lost.
5+
6+
*/
7+
-- RedefineTables
8+
PRAGMA foreign_keys=OFF;
9+
CREATE TABLE "new_Connection" (
10+
"alias" TEXT NOT NULL PRIMARY KEY,
11+
"created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
12+
"updated" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
13+
"description" TEXT,
14+
"connectionString" TEXT NOT NULL,
15+
"driver" TEXT NOT NULL
16+
);
17+
INSERT INTO "new_Connection" ("alias", "connectionString", "created", "description", "driver", "updated") SELECT "alias", "connectionString", "created", "description", "driver", "updated" FROM "Connection";
18+
DROP TABLE "Connection";
19+
ALTER TABLE "new_Connection" RENAME TO "Connection";
20+
CREATE UNIQUE INDEX "Connection_alias_key" ON "Connection"("alias");
21+
CREATE TABLE "new_History" (
22+
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
23+
"created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
24+
"lastUsed" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
25+
"count" INTEGER NOT NULL DEFAULT 1,
26+
"query" TEXT NOT NULL,
27+
"connectionAlias" TEXT NOT NULL,
28+
"success" BOOLEAN NOT NULL,
29+
CONSTRAINT "History_connectionAlias_fkey" FOREIGN KEY ("connectionAlias") REFERENCES "Connection" ("alias") ON DELETE CASCADE ON UPDATE CASCADE
30+
);
31+
INSERT INTO "new_History" ("connectionAlias", "count", "created", "id", "lastUsed", "query", "success") SELECT "connectionAlias", "count", "created", "id", "lastUsed", "query", "success" FROM "History";
32+
DROP TABLE "History";
33+
ALTER TABLE "new_History" RENAME TO "History";
34+
CREATE UNIQUE INDEX "History_query_connectionAlias_key" ON "History"("query", "connectionAlias");
35+
PRAGMA foreign_key_check;
36+
PRAGMA foreign_keys=ON;

prisma/schema.prisma

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ model Connection {
1414
alias String @id @unique
1515
created DateTime @default(now())
1616
updated DateTime @default(now())
17-
editable Boolean @default(true)
1817
description String?
1918
connectionString String
2019
@@ -32,7 +31,7 @@ model History {
3231
count Int @default(1)
3332
query String
3433
35-
connection Connection @relation(fields: [connectionAlias], references: [alias])
34+
connection Connection @relation(fields: [connectionAlias], references: [alias], onDelete: Cascade)
3635
connectionAlias String
3736
success Boolean
3837

src/commands/connection/delete.ts

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export default class Delete extends AppCommand {
2828
const result = await this.sqlqdb.connection.delete({
2929
where: {
3030
alias,
31-
editable: false,
3231
},
3332
})
3433

0 commit comments

Comments
 (0)