mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-22 18:11:32 +03:00
60 lines
2.0 KiB
SQL
60 lines
2.0 KiB
SQL
-- CreateTable
|
|
CREATE TABLE "users" (
|
|
"id" VARCHAR NOT NULL,
|
|
"name" VARCHAR NOT NULL,
|
|
"email" VARCHAR NOT NULL,
|
|
"token_nonce" SMALLINT NOT NULL DEFAULT 0,
|
|
"avatar_url" VARCHAR,
|
|
"password" VARCHAR,
|
|
"fulfilled" BOOLEAN NOT NULL DEFAULT true,
|
|
"created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
CONSTRAINT "users_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "workspaces" (
|
|
"id" VARCHAR NOT NULL,
|
|
"public" BOOLEAN NOT NULL,
|
|
"created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
CONSTRAINT "workspaces_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "connected_accounts" (
|
|
"id" VARCHAR NOT NULL,
|
|
"user_id" TEXT NOT NULL,
|
|
"provider" VARCHAR NOT NULL,
|
|
"provider_user_id" VARCHAR NOT NULL,
|
|
|
|
CONSTRAINT "connected_accounts_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "user_workspace_permissions" (
|
|
"id" VARCHAR NOT NULL,
|
|
"workspace_id" VARCHAR NOT NULL,
|
|
"entity_id" VARCHAR NOT NULL,
|
|
"type" SMALLINT NOT NULL,
|
|
"accepted" BOOLEAN NOT NULL DEFAULT false,
|
|
"created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
CONSTRAINT "user_workspace_permissions_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "users_email_key" ON "users"("email");
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "connected_accounts_provider_user_id_key" ON "connected_accounts"("provider_user_id");
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "connected_accounts" ADD CONSTRAINT "connected_accounts_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "user_workspace_permissions" ADD CONSTRAINT "user_workspace_permissions_workspace_id_fkey" FOREIGN KEY ("workspace_id") REFERENCES "workspaces"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "user_workspace_permissions" ADD CONSTRAINT "user_workspace_permissions_entity_id_fkey" FOREIGN KEY ("entity_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|