-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
182 changed files
with
5,110 additions
and
3,508 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
db/migrations/20231127155246_surveyresponse_rename_surveypart/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "SurveyResponse" RENAME COLUMN "surveyId" TO "surveyPart"; |
23 changes: 23 additions & 0 deletions
23
db/migrations/20231220104810_add_subsubsection_task/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
-- AlterTable | ||
ALTER TABLE "Subsubsection" ADD COLUMN "subsubsectionTaskId" INTEGER; | ||
|
||
-- CreateTable | ||
CREATE TABLE "SubsubsectionTask" ( | ||
"id" SERIAL NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL, | ||
"slug" TEXT NOT NULL, | ||
"title" TEXT NOT NULL, | ||
"projectId" INTEGER NOT NULL, | ||
|
||
CONSTRAINT "SubsubsectionTask_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "SubsubsectionTask_projectId_slug_key" ON "SubsubsectionTask"("projectId", "slug"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Subsubsection" ADD CONSTRAINT "Subsubsection_subsubsectionTaskId_fkey" FOREIGN KEY ("subsubsectionTaskId") REFERENCES "SubsubsectionTask"("id") ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "SubsubsectionTask" ADD CONSTRAINT "SubsubsectionTask_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
23 changes: 23 additions & 0 deletions
23
db/migrations/20231220133742_add_model_subsubsection_infra/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
-- AlterTable | ||
ALTER TABLE "Subsubsection" ADD COLUMN "subsubsectionInfraId" INTEGER; | ||
|
||
-- CreateTable | ||
CREATE TABLE "SubsubsectionInfra" ( | ||
"id" SERIAL NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL, | ||
"slug" TEXT NOT NULL, | ||
"title" TEXT NOT NULL, | ||
"projectId" INTEGER NOT NULL, | ||
|
||
CONSTRAINT "SubsubsectionInfra_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "SubsubsectionInfra_projectId_slug_key" ON "SubsubsectionInfra"("projectId", "slug"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Subsubsection" ADD CONSTRAINT "Subsubsection_subsubsectionInfraId_fkey" FOREIGN KEY ("subsubsectionInfraId") REFERENCES "SubsubsectionInfra"("id") ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "SubsubsectionInfra" ADD CONSTRAINT "SubsubsectionInfra_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
2 changes: 2 additions & 0 deletions
2
db/migrations/20231220161044_add_field_width_existing/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "Subsubsection" ADD COLUMN "widthExisting" DOUBLE PRECISION; |
2 changes: 2 additions & 0 deletions
2
db/migrations/20231220161616_add_field_is_existing_infra/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "Subsubsection" ADD COLUMN "isExistingInfra" BOOLEAN DEFAULT false; |
35 changes: 35 additions & 0 deletions
35
db/migrations/20231222132752_add_model_subsubsection_special/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
-- CreateTable | ||
CREATE TABLE "SubsubsectionSpecial" ( | ||
"id" SERIAL NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL, | ||
"slug" TEXT NOT NULL, | ||
"title" TEXT NOT NULL, | ||
"projectId" INTEGER NOT NULL, | ||
|
||
CONSTRAINT "SubsubsectionSpecial_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "_SubsubsectionToSubsubsectionSpecial" ( | ||
"A" INTEGER NOT NULL, | ||
"B" INTEGER NOT NULL | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "SubsubsectionSpecial_projectId_slug_key" ON "SubsubsectionSpecial"("projectId", "slug"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "_SubsubsectionToSubsubsectionSpecial_AB_unique" ON "_SubsubsectionToSubsubsectionSpecial"("A", "B"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "_SubsubsectionToSubsubsectionSpecial_B_index" ON "_SubsubsectionToSubsubsectionSpecial"("B"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "SubsubsectionSpecial" ADD CONSTRAINT "SubsubsectionSpecial_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "_SubsubsectionToSubsubsectionSpecial" ADD CONSTRAINT "_SubsubsectionToSubsubsectionSpecial_A_fkey" FOREIGN KEY ("A") REFERENCES "Subsubsection"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "_SubsubsectionToSubsubsectionSpecial" ADD CONSTRAINT "_SubsubsectionToSubsubsectionSpecial_B_fkey" FOREIGN KEY ("B") REFERENCES "SubsubsectionSpecial"("id") ON DELETE CASCADE ON UPDATE CASCADE; |
44 changes: 44 additions & 0 deletions
44
db/migrations/20231222160004_migrate_task_to_subsubsection_task_id/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
CREATE OR REPLACE FUNCTION slugify(input_text TEXT) | ||
RETURNS TEXT AS | ||
$$ | ||
DECLARE | ||
slug TEXT; | ||
BEGIN | ||
slug := input_text; | ||
slug := lower(slug); | ||
slug := translate(slug, 'ä,ö,ü,ß', 'a,o,u,s'); | ||
slug := regexp_replace(slug, '[^a-z0-9]+', '-', 'g'); | ||
slug := regexp_replace(slug, '^[-]+|[-]+$', '', 'g'); | ||
RETURN slug; | ||
END; | ||
$$ LANGUAGE plpgsql; | ||
|
||
DO | ||
$$ | ||
DECLARE | ||
v_project_id INTEGER; | ||
v_task TEXT; | ||
BEGIN | ||
FOR v_project_id IN SELECT id FROM "Project" | ||
LOOP | ||
RAISE NOTICE 'Project: %', v_project_id; | ||
FOR v_task IN SELECT DISTINCT task | ||
FROM "Subsubsection" | ||
WHERE "subsectionId" IN | ||
(SELECT id FROM "Subsection" WHERE "projectId" = v_project_id) | ||
LOOP | ||
RAISE NOTICE ' Task: % %s', v_task, slugify(v_task); | ||
INSERT INTO "SubsubsectionTask" ("updatedAt", slug, title, "projectId") | ||
VALUES ('2023-12-20 19:31:21.496', slugify(v_task), v_task, v_project_id); | ||
UPDATE "Subsubsection" | ||
SET "subsubsectionTaskId" = (SELECT id | ||
FROM "SubsubsectionTask" | ||
WHERE "projectId" = v_project_id | ||
AND title = v_task) | ||
WHERE "subsectionId" IN | ||
(SELECT id FROM "Subsection" WHERE "projectId" = v_project_id) | ||
AND task = v_task; | ||
END LOOP; | ||
END LOOP; | ||
END ; | ||
$$; |
2 changes: 2 additions & 0 deletions
2
db/migrations/20240102102343_field_task_optional/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "Subsubsection" ALTER COLUMN "task" DROP NOT NULL; |
2 changes: 2 additions & 0 deletions
2
db/migrations/20240104131012_subsection_add_length_km/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "Subsection" ADD COLUMN "lengthKm" DOUBLE PRECISION; |
2 changes: 2 additions & 0 deletions
2
db/migrations/20240104164750_subsubsection_rename_length/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE "Subsubsection" | ||
RENAME COLUMN "length" TO "lengthKm"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { PrismaClient } from "@prisma/client" | ||
|
||
/* | ||
# TODO: Document why this exists and could be useful | ||
source .env.local | ||
pg_dump $DATABASE_URL --data-only --column-inserts -t 'public."SubsubsectionSpecial"' | grep 'INSERT INTO' | ||
*/ | ||
|
||
const sql = ` | ||
INSERT INTO public."SubsubsectionSpecial" (id, "createdAt", "updatedAt", slug, title, "projectId") VALUES (1, '2023-12-20 19:31:21.496', '2023-12-20 19:31:21.496', 's1', 'Special 1', 1); | ||
INSERT INTO public."SubsubsectionSpecial" (id, "createdAt", "updatedAt", slug, title, "projectId") VALUES (2, '2023-12-20 19:31:29.162', '2023-12-20 19:31:29.162', 's2', 'Special 22', 1); | ||
INSERT INTO public."SubsubsectionSpecial" (id, "createdAt", "updatedAt", slug, title, "projectId") VALUES (3, '2023-12-20 19:31:36.93', '2023-12-20 19:31:36.93', 's3', 'Special 333', 1); | ||
` | ||
|
||
const seedDevData = async () => { | ||
// const prismaClient = new PrismaClient() | ||
// sql.split(';').forEach(statement => prismaClient.$executeRawUnsafe(statement)) | ||
} | ||
|
||
export default seedDevData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.