auth-api/db/migrations/20201207191913_first.sql

21 lines
580 B
MySQL
Raw Normal View History

2020-12-29 13:46:58 +01:00
-- migrate:up
CREATE TABLE "users" (
"id" uuid PRIMARY KEY,
"created" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"username" text NOT NULL,
"password" text NOT NULL
);
CREATE TABLE "usersFields" (
"id" uuid PRIMARY KEY,
"created" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"userId" uuid NOT NULL,
"name" text NOT NULL,
"value" text[] NOT NULL
);
ALTER TABLE "usersFields"
ADD FOREIGN KEY ("userId") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE RESTRICT;
CREATE UNIQUE INDEX idx_usersfields ON "usersFields" ("userId", "name");
-- migrate:down