vue-todo/bbconf/bb_todo-datamodel.sql

46 lines
1.2 KiB
MySQL
Raw Normal View History

--
2023-11-01 03:36:55 +01:00
-- Generated by basebox compiler (bbc) version 0.1.0-beta.23 at 2023-11-01 03:18:33+01:00
--
2023-04-04 19:38:28 +02:00
CREATE EXTENSION IF NOT EXISTS pgcrypto;
2023-02-12 11:36:19 +01:00
CREATE TABLE "List" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"title" VARCHAR NOT NULL,
2023-02-16 22:19:09 +01:00
"user_username" VARCHAR NOT NULL
2023-02-12 11:36:19 +01:00
);
CREATE TABLE "Task" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"title" VARCHAR NOT NULL,
"description" VARCHAR,
"completed" BOOLEAN NOT NULL,
2023-02-16 22:19:09 +01:00
"user_username" VARCHAR NOT NULL,
"list_id" UUID NOT NULL
2023-02-12 11:36:19 +01:00
);
CREATE TABLE "User" (
"username" VARCHAR NOT NULL,
"name" VARCHAR
);
ALTER TABLE "List" ADD PRIMARY KEY ("id");
ALTER TABLE "Task" ADD PRIMARY KEY ("id");
ALTER TABLE "User" ADD PRIMARY KEY ("username");
2023-02-16 22:19:09 +01:00
ALTER TABLE "List" ADD CONSTRAINT fk_list_1 FOREIGN KEY ("user_username") REFERENCES "User" ("username");
2023-02-12 11:36:19 +01:00
2023-02-16 22:19:09 +01:00
ALTER TABLE "Task" ADD CONSTRAINT fk_task_2 FOREIGN KEY ("user_username") REFERENCES "User" ("username");
2023-02-12 11:36:19 +01:00
2023-02-16 22:19:09 +01:00
ALTER TABLE "Task" ADD CONSTRAINT fk_task_3 FOREIGN KEY ("list_id") REFERENCES "List" ("id");
2023-02-12 11:36:19 +01:00
ALTER TABLE "User" ADD CONSTRAINT uq_user_4 UNIQUE (".ownerId");
ALTER TABLE "List" ADD COLUMN ".ownerId" VARCHAR NOT NULL;
ALTER TABLE "Task" ADD COLUMN ".ownerId" VARCHAR NOT NULL;
ALTER TABLE "User" ADD COLUMN ".ownerId" VARCHAR NOT NULL;