Skip to content

Commit f393dee

Browse files
refactor: set uid for ids
1 parent d0782b0 commit f393dee

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
Warnings:
3+
4+
- The primary key for the `IntegrationStatus` table will be changed. If it partially fails, the table could be left without primary key constraint.
5+
- The primary key for the `Webcam` table will be changed. If it partially fails, the table could be left without primary key constraint.
6+
7+
*/
8+
-- DropForeignKey
9+
ALTER TABLE "Webcam" DROP CONSTRAINT "Webcam_integrationStatusId_fkey";
10+
11+
-- AlterTable
12+
ALTER TABLE "IntegrationStatus" DROP CONSTRAINT "IntegrationStatus_pkey",
13+
ALTER COLUMN "id" DROP DEFAULT,
14+
ALTER COLUMN "id" SET DATA TYPE TEXT,
15+
ADD CONSTRAINT "IntegrationStatus_pkey" PRIMARY KEY ("id");
16+
DROP SEQUENCE "IntegrationStatus_id_seq";
17+
18+
-- AlterTable
19+
ALTER TABLE "Webcam" DROP CONSTRAINT "Webcam_pkey",
20+
ALTER COLUMN "id" DROP DEFAULT,
21+
ALTER COLUMN "id" SET DATA TYPE TEXT,
22+
ALTER COLUMN "integrationStatusId" SET DATA TYPE TEXT,
23+
ADD CONSTRAINT "Webcam_pkey" PRIMARY KEY ("id");
24+
DROP SEQUENCE "Webcam_id_seq";
25+
26+
-- AddForeignKey
27+
ALTER TABLE "Webcam" ADD CONSTRAINT "Webcam_integrationStatusId_fkey" FOREIGN KEY ("integrationStatusId") REFERENCES "IntegrationStatus"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

prisma/schema.prisma

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ datasource db {
1414
}
1515

1616
model Webcam {
17-
id Int @id @default(autoincrement())
17+
id String @id @default(cuid())
1818
name String @unique
1919
angleOfView Float
2020
elevation Int?
2121
latitude Float
2222
longitude Float
2323
refreshSeconds Int?
2424
comments String?
25-
integrationStatusId Int
25+
integrationStatusId String
2626
integrationStatus IntegrationStatus @relation(fields: [integrationStatusId], references: [id])
2727
}
2828

2929
model IntegrationStatus {
30-
id Int @id @default(autoincrement())
30+
id String @id @default(cuid())
3131
code String @unique
3232
labelKey String
3333

0 commit comments

Comments
 (0)