Restructure Cockroachdb migrations

Split the migrations to match the other databases. Avoid unsafe BigInt values by using sequences to increment id fields.
This commit is contained in:
Sammy-T 2022-10-24 13:02:43 -04:00
parent 33422d8a6c
commit 2c7fc4108d
5 changed files with 277 additions and 166 deletions

View file

@ -0,0 +1,36 @@
-- AlterTable
ALTER TABLE "account" ADD COLUMN "account_uuid" UUID NULL;
-- Backfill UUID
UPDATE "account" SET account_uuid = gen_random_uuid();
-- AlterTable
ALTER TABLE "account" ALTER COLUMN "account_uuid" SET NOT NULL;
-- CreateIndex
CREATE UNIQUE INDEX "account_account_uuid_key" ON "account"("account_uuid");
-- AlterTable
ALTER TABLE "event" ADD COLUMN "event_uuid" UUID NULL;
-- Backfill UUID
UPDATE "event" SET event_uuid = gen_random_uuid();
-- AlterTable
ALTER TABLE "event" ALTER COLUMN "event_uuid" SET NOT NULL;
-- CreateIndex
CREATE UNIQUE INDEX "event_event_uuid_key" ON "event"("event_uuid");
-- CreateIndex
CREATE INDEX "account_account_uuid_idx" ON "account"("account_uuid");
-- CreateIndex
CREATE INDEX "session_session_uuid_idx" ON "session"("session_uuid");
-- CreateIndex
CREATE INDEX "website_website_uuid_idx" ON "website"("website_uuid");
-- CreateIndex
CREATE INDEX "event_event_uuid_idx" ON "event"("event_uuid");