mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 17:55:08 +01:00
Add 01 migration.
This commit is contained in:
parent
e8e90a5451
commit
8097428a4b
@ -3,8 +3,10 @@ CREATE TABLE "user" (
|
|||||||
"user_id" UUID NOT NULL,
|
"user_id" UUID NOT NULL,
|
||||||
"username" VARCHAR(255) NOT NULL,
|
"username" VARCHAR(255) NOT NULL,
|
||||||
"password" VARCHAR(60) NOT NULL,
|
"password" VARCHAR(60) NOT NULL,
|
||||||
|
"role" VARCHAR(50) NOT NULL,
|
||||||
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
|
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
|
||||||
"is_deleted" BOOLEAN NOT NULL DEFAULT false,
|
"updated_at" TIMESTAMPTZ(6),
|
||||||
|
"deleted_at" TIMESTAMPTZ(6),
|
||||||
|
|
||||||
CONSTRAINT "user_pkey" PRIMARY KEY ("user_id")
|
CONSTRAINT "user_pkey" PRIMARY KEY ("user_id")
|
||||||
);
|
);
|
||||||
@ -35,7 +37,8 @@ CREATE TABLE "website" (
|
|||||||
"user_id" UUID,
|
"user_id" UUID,
|
||||||
"team_id" UUID,
|
"team_id" UUID,
|
||||||
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
|
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
|
||||||
"is_deleted" BOOLEAN NOT NULL DEFAULT false,
|
"updated_at" TIMESTAMPTZ(6),
|
||||||
|
"deleted_at" TIMESTAMPTZ(6),
|
||||||
|
|
||||||
CONSTRAINT "website_pkey" PRIMARY KEY ("website_id")
|
CONSTRAINT "website_pkey" PRIMARY KEY ("website_id")
|
||||||
);
|
);
|
||||||
@ -55,88 +58,14 @@ CREATE TABLE "website_event" (
|
|||||||
CONSTRAINT "website_event_pkey" PRIMARY KEY ("event_id")
|
CONSTRAINT "website_event_pkey" PRIMARY KEY ("event_id")
|
||||||
);
|
);
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "group" (
|
|
||||||
"group_id" UUID NOT NULL,
|
|
||||||
"name" VARCHAR(255) NOT NULL,
|
|
||||||
"description" VARCHAR(255),
|
|
||||||
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"is_deleted" BOOLEAN NOT NULL DEFAULT false,
|
|
||||||
|
|
||||||
CONSTRAINT "group_pkey" PRIMARY KEY ("group_id")
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "group_role" (
|
|
||||||
"group_role_id" UUID NOT NULL,
|
|
||||||
"group_id" UUID NOT NULL,
|
|
||||||
"role_id" UUID NOT NULL,
|
|
||||||
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"is_deleted" BOOLEAN NOT NULL DEFAULT false,
|
|
||||||
"userId" UUID,
|
|
||||||
|
|
||||||
CONSTRAINT "group_role_pkey" PRIMARY KEY ("group_role_id")
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "group_user" (
|
|
||||||
"group_user_id" UUID NOT NULL,
|
|
||||||
"group_id" UUID NOT NULL,
|
|
||||||
"user_id" UUID NOT NULL,
|
|
||||||
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"is_deleted" BOOLEAN NOT NULL DEFAULT false,
|
|
||||||
|
|
||||||
CONSTRAINT "group_user_pkey" PRIMARY KEY ("group_user_id")
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "permission" (
|
|
||||||
"permission_id" UUID NOT NULL,
|
|
||||||
"name" VARCHAR(255) NOT NULL,
|
|
||||||
"description" VARCHAR(255),
|
|
||||||
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
|
|
||||||
CONSTRAINT "permission_pkey" PRIMARY KEY ("permission_id")
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "role" (
|
|
||||||
"role_id" UUID NOT NULL,
|
|
||||||
"name" VARCHAR(255) NOT NULL,
|
|
||||||
"description" VARCHAR(255),
|
|
||||||
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
|
|
||||||
CONSTRAINT "role_pkey" PRIMARY KEY ("role_id")
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "role_permission" (
|
|
||||||
"role_permission_id" UUID NOT NULL,
|
|
||||||
"role_id" UUID NOT NULL,
|
|
||||||
"permission_id" UUID NOT NULL,
|
|
||||||
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"is_deleted" BOOLEAN NOT NULL DEFAULT false,
|
|
||||||
|
|
||||||
CONSTRAINT "role_permission_pkey" PRIMARY KEY ("role_permission_id")
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "user_role" (
|
|
||||||
"user_role_id" UUID NOT NULL,
|
|
||||||
"role_id" UUID NOT NULL,
|
|
||||||
"user_id" UUID NOT NULL,
|
|
||||||
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"is_deleted" BOOLEAN NOT NULL DEFAULT false,
|
|
||||||
|
|
||||||
CONSTRAINT "user_role_pkey" PRIMARY KEY ("user_role_id")
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
-- CreateTable
|
||||||
CREATE TABLE "team" (
|
CREATE TABLE "team" (
|
||||||
"team_id" UUID NOT NULL,
|
"team_id" UUID NOT NULL,
|
||||||
"name" VARCHAR(50) NOT NULL,
|
"name" VARCHAR(50) NOT NULL,
|
||||||
|
"user_id" UUID NOT NULL,
|
||||||
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
|
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
|
||||||
"is_deleted" BOOLEAN NOT NULL DEFAULT false,
|
"updated_at" TIMESTAMPTZ(6),
|
||||||
|
"deleted_at" TIMESTAMPTZ(6),
|
||||||
|
|
||||||
CONSTRAINT "team_pkey" PRIMARY KEY ("team_id")
|
CONSTRAINT "team_pkey" PRIMARY KEY ("team_id")
|
||||||
);
|
);
|
||||||
@ -146,9 +75,10 @@ CREATE TABLE "team_user" (
|
|||||||
"team_user_id" UUID NOT NULL,
|
"team_user_id" UUID NOT NULL,
|
||||||
"team_id" UUID NOT NULL,
|
"team_id" UUID NOT NULL,
|
||||||
"user_id" UUID NOT NULL,
|
"user_id" UUID NOT NULL,
|
||||||
"role_id" UUID NOT NULL,
|
"role" VARCHAR(50) NOT NULL,
|
||||||
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
|
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
|
||||||
"is_deleted" BOOLEAN NOT NULL DEFAULT false,
|
"updated_at" TIMESTAMPTZ(6),
|
||||||
|
"deleted_at" TIMESTAMPTZ(6),
|
||||||
|
|
||||||
CONSTRAINT "team_user_pkey" PRIMARY KEY ("team_user_id")
|
CONSTRAINT "team_user_pkey" PRIMARY KEY ("team_user_id")
|
||||||
);
|
);
|
||||||
@ -195,48 +125,9 @@ CREATE INDEX "website_event_website_id_created_at_idx" ON "website_event"("websi
|
|||||||
-- CreateIndex
|
-- CreateIndex
|
||||||
CREATE INDEX "website_event_website_id_session_id_created_at_idx" ON "website_event"("website_id", "session_id", "created_at");
|
CREATE INDEX "website_event_website_id_session_id_created_at_idx" ON "website_event"("website_id", "session_id", "created_at");
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "group_group_id_key" ON "group"("group_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "group_name_key" ON "group"("name");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "group_role_group_role_id_key" ON "group_role"("group_role_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "group_user_group_user_id_key" ON "group_user"("group_user_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "permission_permission_id_key" ON "permission"("permission_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "permission_name_key" ON "permission"("name");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "role_role_id_key" ON "role"("role_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "role_name_key" ON "role"("name");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "role_permission_role_permission_id_key" ON "role_permission"("role_permission_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "role_permission_role_id_permission_id_key" ON "role_permission"("role_id", "permission_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "user_role_user_role_id_key" ON "user_role"("user_role_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "user_role_role_id_user_id_key" ON "user_role"("role_id", "user_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
-- CreateIndex
|
||||||
CREATE UNIQUE INDEX "team_team_id_key" ON "team"("team_id");
|
CREATE UNIQUE INDEX "team_team_id_key" ON "team"("team_id");
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "team_name_key" ON "team"("name");
|
|
||||||
|
|
||||||
-- CreateIndex
|
-- CreateIndex
|
||||||
CREATE UNIQUE INDEX "team_user_team_user_id_key" ON "team_user"("team_user_id");
|
CREATE UNIQUE INDEX "team_user_team_user_id_key" ON "team_user"("team_user_id");
|
||||||
|
|
||||||
@ -246,87 +137,11 @@ ALTER TABLE "website" ADD CONSTRAINT "website_team_id_fkey" FOREIGN KEY ("team_i
|
|||||||
-- AddForeignKey
|
-- AddForeignKey
|
||||||
ALTER TABLE "website" ADD CONSTRAINT "website_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("user_id") ON DELETE SET NULL ON UPDATE CASCADE;
|
ALTER TABLE "website" ADD CONSTRAINT "website_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("user_id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "group_role" ADD CONSTRAINT "group_role_group_id_fkey" FOREIGN KEY ("group_id") REFERENCES "group"("group_id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "group_role" ADD CONSTRAINT "group_role_role_id_fkey" FOREIGN KEY ("role_id") REFERENCES "role"("role_id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "group_role" ADD CONSTRAINT "group_role_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("user_id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "group_user" ADD CONSTRAINT "group_user_group_id_fkey" FOREIGN KEY ("group_id") REFERENCES "group"("group_id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "group_user" ADD CONSTRAINT "group_user_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("user_id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "role_permission" ADD CONSTRAINT "role_permission_role_id_fkey" FOREIGN KEY ("role_id") REFERENCES "role"("role_id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "role_permission" ADD CONSTRAINT "role_permission_permission_id_fkey" FOREIGN KEY ("permission_id") REFERENCES "permission"("permission_id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "user_role" ADD CONSTRAINT "user_role_role_id_fkey" FOREIGN KEY ("role_id") REFERENCES "role"("role_id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "user_role" ADD CONSTRAINT "user_role_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("user_id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
||||||
|
|
||||||
-- AddForeignKey
|
-- AddForeignKey
|
||||||
ALTER TABLE "team_user" ADD CONSTRAINT "team_user_team_id_fkey" FOREIGN KEY ("team_id") REFERENCES "team"("team_id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
ALTER TABLE "team_user" ADD CONSTRAINT "team_user_team_id_fkey" FOREIGN KEY ("team_id") REFERENCES "team"("team_id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
-- AddForeignKey
|
-- AddForeignKey
|
||||||
ALTER TABLE "team_user" ADD CONSTRAINT "team_user_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("user_id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
ALTER TABLE "team_user" ADD CONSTRAINT "team_user_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("user_id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
-- AddForeignKey
|
-- AddSystemUser
|
||||||
ALTER TABLE "team_user" ADD CONSTRAINT "team_user_role_id_fkey" FOREIGN KEY ("role_id") REFERENCES "role"("role_id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
||||||
|
|
||||||
-- Add System User
|
|
||||||
INSERT INTO "user" (user_id, username, password) VALUES ('41e2b680-648e-4b09-bcd7-3e2b10c06264' ,'admin', '$2b$10$BUli0c.muyCW1ErNJc3jL.vFRFtFJWrT8/GcR4A.sUdCznaXiqFXa');
|
INSERT INTO "user" (user_id, username, password) VALUES ('41e2b680-648e-4b09-bcd7-3e2b10c06264' ,'admin', '$2b$10$BUli0c.muyCW1ErNJc3jL.vFRFtFJWrT8/GcR4A.sUdCznaXiqFXa');
|
||||||
|
|
||||||
-- Add Roles
|
|
||||||
INSERT INTO "role" ("role_id", "name", "description") VALUES (gen_random_uuid(), 'Admin', 'System Admin.');
|
|
||||||
INSERT INTO "role" ("role_id", "name", "description") VALUES (gen_random_uuid(), 'Member', 'Create and maintain websites.');
|
|
||||||
INSERT INTO "role" ("role_id", "name", "description") VALUES (gen_random_uuid(), 'Team Owner', 'Create and maintain the team, memberships, websites, and responsible for billing.');
|
|
||||||
INSERT INTO "role" ("role_id", "name", "description") VALUES (gen_random_uuid(), 'Team Member', 'Create and maintain websites.');
|
|
||||||
INSERT INTO "role" ("role_id", "name", "description") VALUES (gen_random_uuid(), 'Team Guest', 'View Websites.');
|
|
||||||
|
|
||||||
-- Add Permissions
|
|
||||||
INSERT INTO "permission" ("permission_id", "name", "description") VALUES (gen_random_uuid(), 'admin', 'System Admin');
|
|
||||||
INSERT INTO "permission" ("permission_id", "name", "description") VALUES (gen_random_uuid(), 'website:create', 'Create website');
|
|
||||||
INSERT INTO "permission" ("permission_id", "name", "description") VALUES (gen_random_uuid(), 'website:read', 'Read website');
|
|
||||||
INSERT INTO "permission" ("permission_id", "name", "description") VALUES (gen_random_uuid(), 'website:update', 'Update website');
|
|
||||||
INSERT INTO "permission" ("permission_id", "name", "description") VALUES (gen_random_uuid(), 'website:delete', 'Delete website');
|
|
||||||
INSERT INTO "permission" ("permission_id", "name", "description") VALUES (gen_random_uuid(), 'website:reset', 'Reset website');
|
|
||||||
INSERT INTO "permission" ("permission_id", "name", "description") VALUES (gen_random_uuid(), 'team:create', 'Create team');
|
|
||||||
INSERT INTO "permission" ("permission_id", "name", "description") VALUES (gen_random_uuid(), 'team:update', 'Update team');
|
|
||||||
INSERT INTO "permission" ("permission_id", "name", "description") VALUES (gen_random_uuid(), 'team:delete', 'Delete team');
|
|
||||||
INSERT INTO "permission" ("permission_id", "name", "description") VALUES (gen_random_uuid(), 'team:add-user', 'Add team member');
|
|
||||||
INSERT INTO "permission" ("permission_id", "name", "description") VALUES (gen_random_uuid(), 'team:remove-user', 'Remove team member');
|
|
||||||
|
|
||||||
-- Add Permissions to Roles
|
|
||||||
INSERT INTO "role_permission"
|
|
||||||
SELECT gen_random_uuid(), "role_id", "permission_id"
|
|
||||||
FROM "role" r JOIN "permission" p ON 0 = 0
|
|
||||||
WHERE r.name = 'Admin' AND p.name = 'admin';
|
|
||||||
|
|
||||||
INSERT INTO "role_permission"
|
|
||||||
SELECT gen_random_uuid(), "role_id", "permission_id"
|
|
||||||
FROM "role" r JOIN "permission" p ON 0 = 0
|
|
||||||
WHERE r.name = 'Member' AND p.name in ('website:create', 'website:read', 'website:update', 'website:delete', 'website:reset', 'team:create');
|
|
||||||
|
|
||||||
INSERT INTO "role_permission"
|
|
||||||
SELECT gen_random_uuid(), "role_id", "permission_id"
|
|
||||||
FROM "role" r JOIN "permission" p ON 0 = 0
|
|
||||||
WHERE r.name = 'Team Owner' AND p.name in ('website:create', 'website:read', 'website:update', 'website:delete', 'website:reset', 'team:create', 'team:update', 'team:delete', 'team:add-user', 'team:remove-user');
|
|
||||||
|
|
||||||
INSERT INTO "role_permission"
|
|
||||||
SELECT gen_random_uuid(), "role_id", "permission_id"
|
|
||||||
FROM "role" r JOIN "permission" p ON 0 = 0
|
|
||||||
WHERE r.name = 'Team Member' AND p.name in ('website:create', 'website:read', 'website:update', 'website:delete', 'website:reset');
|
|
||||||
|
|
||||||
INSERT INTO "role_permission"
|
|
||||||
SELECT gen_random_uuid(), "role_id", "permission_id"
|
|
||||||
FROM "role" r JOIN "permission" p ON 0 = 0
|
|
||||||
WHERE r.name = 'Team Guest' AND p.name in ('website:read');
|
|
@ -1,74 +0,0 @@
|
|||||||
/*
|
|
||||||
Warnings:
|
|
||||||
|
|
||||||
- You are about to drop the column `role_id` on the `team_user` table. All the data in the column will be lost.
|
|
||||||
- You are about to drop the column `role_id` on the `user_role` table. All the data in the column will be lost.
|
|
||||||
- You are about to drop the `group` table. If the table is not empty, all the data it contains will be lost.
|
|
||||||
- You are about to drop the `group_role` table. If the table is not empty, all the data it contains will be lost.
|
|
||||||
- You are about to drop the `group_user` table. If the table is not empty, all the data it contains will be lost.
|
|
||||||
- You are about to drop the `permission` table. If the table is not empty, all the data it contains will be lost.
|
|
||||||
- You are about to drop the `role` table. If the table is not empty, all the data it contains will be lost.
|
|
||||||
- You are about to drop the `role_permission` table. If the table is not empty, all the data it contains will be lost.
|
|
||||||
- A unique constraint covering the columns `[role,user_id]` on the table `user_role` will be added. If there are existing duplicate values, this will fail.
|
|
||||||
- Added the required column `role` to the `team_user` table without a default value. This is not possible if the table is not empty.
|
|
||||||
- Added the required column `role` to the `user_role` table without a default value. This is not possible if the table is not empty.
|
|
||||||
|
|
||||||
*/
|
|
||||||
-- DropForeignKey
|
|
||||||
ALTER TABLE "group_role" DROP CONSTRAINT "group_role_group_id_fkey";
|
|
||||||
|
|
||||||
-- DropForeignKey
|
|
||||||
ALTER TABLE "group_role" DROP CONSTRAINT "group_role_role_id_fkey";
|
|
||||||
|
|
||||||
-- DropForeignKey
|
|
||||||
ALTER TABLE "group_role" DROP CONSTRAINT "group_role_userId_fkey";
|
|
||||||
|
|
||||||
-- DropForeignKey
|
|
||||||
ALTER TABLE "group_user" DROP CONSTRAINT "group_user_group_id_fkey";
|
|
||||||
|
|
||||||
-- DropForeignKey
|
|
||||||
ALTER TABLE "group_user" DROP CONSTRAINT "group_user_user_id_fkey";
|
|
||||||
|
|
||||||
-- DropForeignKey
|
|
||||||
ALTER TABLE "role_permission" DROP CONSTRAINT "role_permission_permission_id_fkey";
|
|
||||||
|
|
||||||
-- DropForeignKey
|
|
||||||
ALTER TABLE "role_permission" DROP CONSTRAINT "role_permission_role_id_fkey";
|
|
||||||
|
|
||||||
-- DropForeignKey
|
|
||||||
ALTER TABLE "team_user" DROP CONSTRAINT "team_user_role_id_fkey";
|
|
||||||
|
|
||||||
-- DropForeignKey
|
|
||||||
ALTER TABLE "user_role" DROP CONSTRAINT "user_role_role_id_fkey";
|
|
||||||
|
|
||||||
-- DropIndex
|
|
||||||
DROP INDEX "user_role_role_id_user_id_key";
|
|
||||||
|
|
||||||
-- AlterTable
|
|
||||||
ALTER TABLE "team_user" DROP COLUMN "role_id",
|
|
||||||
ADD COLUMN "role" VARCHAR(100) NOT NULL;
|
|
||||||
|
|
||||||
-- AlterTable
|
|
||||||
ALTER TABLE "user_role" DROP COLUMN "role_id",
|
|
||||||
ADD COLUMN "role" VARCHAR(100) NOT NULL;
|
|
||||||
|
|
||||||
-- DropTable
|
|
||||||
DROP TABLE "group";
|
|
||||||
|
|
||||||
-- DropTable
|
|
||||||
DROP TABLE "group_role";
|
|
||||||
|
|
||||||
-- DropTable
|
|
||||||
DROP TABLE "group_user";
|
|
||||||
|
|
||||||
-- DropTable
|
|
||||||
DROP TABLE "permission";
|
|
||||||
|
|
||||||
-- DropTable
|
|
||||||
DROP TABLE "role";
|
|
||||||
|
|
||||||
-- DropTable
|
|
||||||
DROP TABLE "role_permission";
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "user_role_role_user_id_key" ON "user_role"("role", "user_id");
|
|
Loading…
Reference in New Issue
Block a user