1130 lines
49 KiB
MySQL
1130 lines
49 KiB
MySQL
|
|
BEGIN;
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class Address as table address
|
||
|
|
--
|
||
|
|
CREATE TABLE "address" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"street" TEXT NOT NULL,
|
||
|
|
"inhabitantId" BLOB,
|
||
|
|
CONSTRAINT "address_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||
|
|
CONSTRAINT "address_fk_1" FOREIGN KEY ("inhabitantId") REFERENCES "person" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "address__inhabitantId__unique_idx" ON "address" ("inhabitantId");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class City as table city
|
||
|
|
--
|
||
|
|
CREATE TABLE "city" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"name" TEXT NOT NULL,
|
||
|
|
CONSTRAINT "city_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class Company as table company
|
||
|
|
--
|
||
|
|
CREATE TABLE "company" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"name" TEXT NOT NULL,
|
||
|
|
"townId" BLOB NOT NULL DEFAULT (X'550e8400e29b41d4a716446655440000'),
|
||
|
|
CONSTRAINT "company_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||
|
|
CONSTRAINT "company_fk_1" FOREIGN KEY ("townId") REFERENCES "town" ("id") ON DELETE SET DEFAULT ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class FkChainCascadeMiddle as table fk_chain_cascade_middle
|
||
|
|
--
|
||
|
|
CREATE TABLE "fk_chain_cascade_middle" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"name" TEXT NOT NULL,
|
||
|
|
"rootId" BLOB,
|
||
|
|
CONSTRAINT "fk_chain_cascade_middle_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||
|
|
CONSTRAINT "fk_chain_cascade_middle_fk_1" FOREIGN KEY ("rootId") REFERENCES "fk_chain_root" ("id") ON DELETE CASCADE ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class FkChainMiddleCascadeChild as table fk_chain_middle_cascade_child
|
||
|
|
--
|
||
|
|
CREATE TABLE "fk_chain_middle_cascade_child" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"name" TEXT NOT NULL,
|
||
|
|
"restrictBlockerId" BLOB,
|
||
|
|
CONSTRAINT "fk_chain_middle_cascade_child_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||
|
|
CONSTRAINT "fk_chain_middle_cascade_child_fk_1" FOREIGN KEY ("restrictBlockerId") REFERENCES "fk_chain_restrict_blocker" ("id") ON DELETE CASCADE ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class FkChainMiddleSetNullChild as table fk_chain_middle_set_null_child
|
||
|
|
--
|
||
|
|
CREATE TABLE "fk_chain_middle_set_null_child" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"name" TEXT NOT NULL,
|
||
|
|
"restrictBlockerId" BLOB,
|
||
|
|
CONSTRAINT "fk_chain_middle_set_null_child_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||
|
|
CONSTRAINT "fk_chain_middle_set_null_child_fk_1" FOREIGN KEY ("restrictBlockerId") REFERENCES "fk_chain_restrict_blocker" ("id") ON DELETE SET NULL ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class FkChainRestrictBlocker as table fk_chain_restrict_blocker
|
||
|
|
--
|
||
|
|
CREATE TABLE "fk_chain_restrict_blocker" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"name" TEXT NOT NULL,
|
||
|
|
"cascadeMiddleId" BLOB,
|
||
|
|
CONSTRAINT "fk_chain_restrict_blocker_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||
|
|
CONSTRAINT "fk_chain_restrict_blocker_fk_1" FOREIGN KEY ("cascadeMiddleId") REFERENCES "fk_chain_cascade_middle" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class FkChainRoot as table fk_chain_root
|
||
|
|
--
|
||
|
|
CREATE TABLE "fk_chain_root" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"name" TEXT NOT NULL,
|
||
|
|
CONSTRAINT "fk_chain_root_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class FkChainSetNullCascadeChild as table fk_chain_set_null_cascade_child
|
||
|
|
--
|
||
|
|
CREATE TABLE "fk_chain_set_null_cascade_child" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"name" TEXT NOT NULL,
|
||
|
|
"setNullMiddleId" BLOB,
|
||
|
|
CONSTRAINT "fk_chain_set_null_cascade_child_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||
|
|
CONSTRAINT "fk_chain_set_null_cascade_child_fk_1" FOREIGN KEY ("setNullMiddleId") REFERENCES "fk_chain_set_null_middle" ("id") ON DELETE CASCADE ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class FkChainSetNullMiddle as table fk_chain_set_null_middle
|
||
|
|
--
|
||
|
|
CREATE TABLE "fk_chain_set_null_middle" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"name" TEXT NOT NULL,
|
||
|
|
"cascadeMiddleId" BLOB,
|
||
|
|
CONSTRAINT "fk_chain_set_null_middle_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||
|
|
CONSTRAINT "fk_chain_set_null_middle_fk_1" FOREIGN KEY ("cascadeMiddleId") REFERENCES "fk_chain_cascade_middle" ("id") ON DELETE SET NULL ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class FkChainSetNullRestrictChild as table fk_chain_set_null_restrict_child
|
||
|
|
--
|
||
|
|
CREATE TABLE "fk_chain_set_null_restrict_child" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"name" TEXT NOT NULL,
|
||
|
|
"setNullMiddleId" BLOB,
|
||
|
|
CONSTRAINT "fk_chain_set_null_restrict_child_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||
|
|
CONSTRAINT "fk_chain_set_null_restrict_child_fk_1" FOREIGN KEY ("setNullMiddleId") REFERENCES "fk_chain_set_null_middle" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class FkChainSetNullSetNullChild as table fk_chain_set_null_set_null_child
|
||
|
|
--
|
||
|
|
CREATE TABLE "fk_chain_set_null_set_null_child" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"name" TEXT NOT NULL,
|
||
|
|
"setNullMiddleId" BLOB,
|
||
|
|
CONSTRAINT "fk_chain_set_null_set_null_child_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||
|
|
CONSTRAINT "fk_chain_set_null_set_null_child_fk_1" FOREIGN KEY ("setNullMiddleId") REFERENCES "fk_chain_set_null_middle" ("id") ON DELETE SET NULL ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class Organization as table organization
|
||
|
|
--
|
||
|
|
CREATE TABLE "organization" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"name" TEXT NOT NULL,
|
||
|
|
"cityId" BLOB,
|
||
|
|
CONSTRAINT "organization_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||
|
|
CONSTRAINT "organization_fk_1" FOREIGN KEY ("cityId") REFERENCES "city" ("id") ON DELETE CASCADE ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class Person as table person
|
||
|
|
--
|
||
|
|
CREATE TABLE "person" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"name" TEXT NOT NULL,
|
||
|
|
"surname" TEXT,
|
||
|
|
"organizationId" BLOB,
|
||
|
|
"oldCompanyId" BLOB,
|
||
|
|
"cityId" BLOB,
|
||
|
|
CONSTRAINT "person_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||
|
|
CONSTRAINT "person_fk_1" FOREIGN KEY ("organizationId") REFERENCES "organization" ("id") ON DELETE CASCADE ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED,
|
||
|
|
CONSTRAINT "person_fk_2" FOREIGN KEY ("oldCompanyId") REFERENCES "company" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||
|
|
CONSTRAINT "person_fk_3" FOREIGN KEY ("cityId") REFERENCES "city" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class RequiredSetNullChild as table required_set_null_child
|
||
|
|
--
|
||
|
|
CREATE TABLE "required_set_null_child" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"name" TEXT NOT NULL,
|
||
|
|
"parentId" BLOB NOT NULL,
|
||
|
|
CONSTRAINT "required_set_null_child_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||
|
|
CONSTRAINT "required_set_null_child_fk_1" FOREIGN KEY ("parentId") REFERENCES "person" ("id") ON DELETE SET NULL ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class RestrictChild as table restrict_child
|
||
|
|
--
|
||
|
|
CREATE TABLE "restrict_child" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"name" TEXT NOT NULL,
|
||
|
|
"parentId" BLOB,
|
||
|
|
CONSTRAINT "restrict_child_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||
|
|
CONSTRAINT "restrict_child_fk_1" FOREIGN KEY ("parentId") REFERENCES "person" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class Town as table town
|
||
|
|
--
|
||
|
|
CREATE TABLE "town" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"name" TEXT NOT NULL,
|
||
|
|
"cityId" BLOB,
|
||
|
|
"mayorId" BLOB,
|
||
|
|
CONSTRAINT "town_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||
|
|
CONSTRAINT "town_fk_1" FOREIGN KEY ("cityId") REFERENCES "city" ("id") ON DELETE CASCADE ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED,
|
||
|
|
CONSTRAINT "town_fk_2" FOREIGN KEY ("mayorId") REFERENCES "person" ("id") ON DELETE SET NULL ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class Types as table types
|
||
|
|
--
|
||
|
|
CREATE TABLE "types" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"aBool" INTEGER NOT NULL,
|
||
|
|
"aDateTime" INTEGER NOT NULL,
|
||
|
|
"aText" TEXT NOT NULL,
|
||
|
|
"anInt" INTEGER NOT NULL,
|
||
|
|
"anInt64" TEXT NOT NULL,
|
||
|
|
"aReal" REAL NOT NULL,
|
||
|
|
"aBlob" BLOB NOT NULL,
|
||
|
|
"anEnum" INTEGER,
|
||
|
|
"optionalText" TEXT,
|
||
|
|
"optionalUuid" BLOB,
|
||
|
|
CONSTRAINT "types_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE INDEX "types_a_text_idx" ON "types" ("aText");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class Unique as table unique
|
||
|
|
--
|
||
|
|
CREATE TABLE "unique" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"name" TEXT NOT NULL,
|
||
|
|
CONSTRAINT "unique_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "unique__scopeId__name__unique_idx" ON "unique" ("scopeId", "name");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class UniqueCascadeChild as table unique_cascade_child
|
||
|
|
--
|
||
|
|
CREATE TABLE "unique_cascade_child" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"name" TEXT NOT NULL,
|
||
|
|
"parentId" BLOB,
|
||
|
|
CONSTRAINT "unique_cascade_child_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||
|
|
CONSTRAINT "unique_cascade_child_fk_1" FOREIGN KEY ("parentId") REFERENCES "person" ("id") ON DELETE CASCADE ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "unique_cascade_child__scopeId__name__unique_idx" ON "unique_cascade_child" ("scopeId", "name");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class UniqueComposite as table unique_composite
|
||
|
|
--
|
||
|
|
CREATE TABLE "unique_composite" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"scope" TEXT NOT NULL,
|
||
|
|
"value" TEXT NOT NULL,
|
||
|
|
CONSTRAINT "unique_composite_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "unique_composite__scopeId__scope__value__unique_idx" ON "unique_composite" ("scopeId", "scope", "value");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class UniqueDiscriminator as table unique_discriminator
|
||
|
|
--
|
||
|
|
CREATE TABLE "unique_discriminator" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"categoryId" INTEGER NOT NULL,
|
||
|
|
"name" TEXT NOT NULL,
|
||
|
|
CONSTRAINT "unique_discriminator_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "unique_discriminator__scopeId__categoryId__name__unique_idx" ON "unique_discriminator" ("scopeId", "categoryId", "name");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class UniqueFkPair as table unique_fk_pair
|
||
|
|
--
|
||
|
|
CREATE TABLE "unique_fk_pair" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"name" TEXT NOT NULL,
|
||
|
|
"leftId" BLOB,
|
||
|
|
"rightId" BLOB,
|
||
|
|
CONSTRAINT "unique_fk_pair_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||
|
|
CONSTRAINT "unique_fk_pair_fk_1" FOREIGN KEY ("leftId") REFERENCES "person" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED,
|
||
|
|
CONSTRAINT "unique_fk_pair_fk_2" FOREIGN KEY ("rightId") REFERENCES "person" ("id") ON DELETE SET NULL ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "unique_fk_pair_parents" ON "unique_fk_pair" ("leftId", "rightId");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class UniqueMixedFk as table unique_mixed_fk
|
||
|
|
--
|
||
|
|
CREATE TABLE "unique_mixed_fk" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"name" TEXT NOT NULL,
|
||
|
|
"parentId" BLOB,
|
||
|
|
CONSTRAINT "unique_mixed_fk_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||
|
|
CONSTRAINT "unique_mixed_fk_fk_1" FOREIGN KEY ("parentId") REFERENCES "person" ("id") ON DELETE CASCADE ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "unique_mixed_fk_name_parent" ON "unique_mixed_fk" ("scopeId", "name", "parentId");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class UniqueNoRelease as table unique_no_release
|
||
|
|
--
|
||
|
|
CREATE TABLE "unique_no_release" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"categoryId" INTEGER NOT NULL,
|
||
|
|
CONSTRAINT "unique_no_release_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "unique_no_release__scopeId__categoryId__unique_idx" ON "unique_no_release" ("scopeId", "categoryId");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class UniqueNullable as table unique_nullable
|
||
|
|
--
|
||
|
|
CREATE TABLE "unique_nullable" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"value" INTEGER,
|
||
|
|
CONSTRAINT "unique_nullable_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "unique_nullable__scopeId__value__unique_idx" ON "unique_nullable" ("scopeId", "value");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class UniqueOverlapping as table unique_overlapping
|
||
|
|
--
|
||
|
|
CREATE TABLE "unique_overlapping" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"first" TEXT NOT NULL,
|
||
|
|
"second" TEXT NOT NULL,
|
||
|
|
"third" TEXT NOT NULL,
|
||
|
|
CONSTRAINT "unique_overlapping_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "unique_overlapping_first_second" ON "unique_overlapping" ("scopeId", "first", "second");
|
||
|
|
CREATE UNIQUE INDEX "unique_overlapping_second_third" ON "unique_overlapping" ("scopeId", "second", "third");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class UniqueSetNullChild as table unique_set_null_child
|
||
|
|
--
|
||
|
|
CREATE TABLE "unique_set_null_child" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"name" TEXT NOT NULL,
|
||
|
|
"parentId" BLOB,
|
||
|
|
CONSTRAINT "unique_set_null_child_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||
|
|
CONSTRAINT "unique_set_null_child_fk_1" FOREIGN KEY ("parentId") REFERENCES "person" ("id") ON DELETE SET NULL ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "unique_set_null_child__parentId__unique_idx" ON "unique_set_null_child" ("parentId");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class UniqueUuid as table unique_uuid
|
||
|
|
--
|
||
|
|
CREATE TABLE "unique_uuid" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"scopeId" INTEGER,
|
||
|
|
"value" BLOB NOT NULL,
|
||
|
|
CONSTRAINT "unique_uuid_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "unique_uuid__scopeId__value__unique_idx" ON "unique_uuid" ("scopeId", "value");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class CloudStorageEntry as table serverpod_cloud_storage
|
||
|
|
--
|
||
|
|
CREATE TABLE "serverpod_cloud_storage" (
|
||
|
|
"id" INTEGER PRIMARY KEY,
|
||
|
|
"storageId" TEXT NOT NULL,
|
||
|
|
"path" TEXT NOT NULL,
|
||
|
|
"addedTime" INTEGER NOT NULL,
|
||
|
|
"expiration" INTEGER,
|
||
|
|
"byteData" BLOB NOT NULL,
|
||
|
|
"verified" INTEGER NOT NULL,
|
||
|
|
"contentType" TEXT,
|
||
|
|
"cacheControl" TEXT,
|
||
|
|
"contentDisposition" TEXT,
|
||
|
|
"contentEncoding" TEXT,
|
||
|
|
"customMetadata" TEXT
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "serverpod_cloud_storage_path_idx" ON "serverpod_cloud_storage" ("storageId", "path");
|
||
|
|
CREATE INDEX "serverpod_cloud_storage_expiration" ON "serverpod_cloud_storage" ("expiration");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class CloudStorageDirectDownloadEntry as table serverpod_cloud_storage_direct_download
|
||
|
|
--
|
||
|
|
CREATE TABLE "serverpod_cloud_storage_direct_download" (
|
||
|
|
"id" INTEGER PRIMARY KEY,
|
||
|
|
"storageId" TEXT NOT NULL,
|
||
|
|
"path" TEXT NOT NULL,
|
||
|
|
"expiration" INTEGER NOT NULL,
|
||
|
|
"authKey" TEXT NOT NULL,
|
||
|
|
"downloadFileName" TEXT,
|
||
|
|
"contentType" TEXT
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "serverpod_cloud_storage_direct_download_auth_key" ON "serverpod_cloud_storage_direct_download" ("authKey");
|
||
|
|
CREATE INDEX "serverpod_cloud_storage_direct_download_expiration" ON "serverpod_cloud_storage_direct_download" ("expiration");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class CloudStorageDirectUploadEntry as table serverpod_cloud_storage_direct_upload
|
||
|
|
--
|
||
|
|
CREATE TABLE "serverpod_cloud_storage_direct_upload" (
|
||
|
|
"id" INTEGER PRIMARY KEY,
|
||
|
|
"storageId" TEXT NOT NULL,
|
||
|
|
"path" TEXT NOT NULL,
|
||
|
|
"expiration" INTEGER NOT NULL,
|
||
|
|
"authKey" TEXT NOT NULL,
|
||
|
|
"maxFileSize" INTEGER NOT NULL DEFAULT (10485760),
|
||
|
|
"contentLength" INTEGER,
|
||
|
|
"preventOverwrite" INTEGER NOT NULL DEFAULT (0),
|
||
|
|
"contentType" TEXT,
|
||
|
|
"cacheControl" TEXT,
|
||
|
|
"contentDisposition" TEXT,
|
||
|
|
"contentEncoding" TEXT,
|
||
|
|
"customMetadata" TEXT
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "serverpod_cloud_storage_direct_upload_storage_path" ON "serverpod_cloud_storage_direct_upload" ("storageId", "path");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class FutureCallEntry as table serverpod_future_call
|
||
|
|
--
|
||
|
|
CREATE TABLE "serverpod_future_call" (
|
||
|
|
"id" INTEGER PRIMARY KEY,
|
||
|
|
"name" TEXT NOT NULL,
|
||
|
|
"time" INTEGER NOT NULL,
|
||
|
|
"serializedObject" TEXT,
|
||
|
|
"serverId" TEXT NOT NULL,
|
||
|
|
"identifier" TEXT,
|
||
|
|
"scheduling" TEXT
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE INDEX "serverpod_future_call_time_idx" ON "serverpod_future_call" ("time");
|
||
|
|
CREATE INDEX "serverpod_future_call_serverId_idx" ON "serverpod_future_call" ("serverId");
|
||
|
|
CREATE INDEX "serverpod_future_call_identifier_idx" ON "serverpod_future_call" ("identifier");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class FutureCallClaimEntry as table serverpod_future_call_claim
|
||
|
|
--
|
||
|
|
CREATE TABLE "serverpod_future_call_claim" (
|
||
|
|
"id" INTEGER PRIMARY KEY,
|
||
|
|
"futureCallId" INTEGER,
|
||
|
|
"lastHeartbeatTime" INTEGER NOT NULL,
|
||
|
|
CONSTRAINT "serverpod_future_call_claim_fk_0" FOREIGN KEY ("futureCallId") REFERENCES "serverpod_future_call" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "future_call_unique_idx" ON "serverpod_future_call_claim" ("futureCallId");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class ServerHealthConnectionInfo as table serverpod_health_connection_info
|
||
|
|
--
|
||
|
|
CREATE TABLE "serverpod_health_connection_info" (
|
||
|
|
"id" INTEGER PRIMARY KEY,
|
||
|
|
"serverId" TEXT NOT NULL,
|
||
|
|
"timestamp" INTEGER NOT NULL,
|
||
|
|
"active" INTEGER NOT NULL,
|
||
|
|
"closing" INTEGER NOT NULL,
|
||
|
|
"idle" INTEGER NOT NULL,
|
||
|
|
"granularity" INTEGER NOT NULL
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "serverpod_health_connection_info_timestamp_idx" ON "serverpod_health_connection_info" ("timestamp", "serverId", "granularity");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class ServerHealthMetric as table serverpod_health_metric
|
||
|
|
--
|
||
|
|
CREATE TABLE "serverpod_health_metric" (
|
||
|
|
"id" INTEGER PRIMARY KEY,
|
||
|
|
"name" TEXT NOT NULL,
|
||
|
|
"serverId" TEXT NOT NULL,
|
||
|
|
"timestamp" INTEGER NOT NULL,
|
||
|
|
"isHealthy" INTEGER NOT NULL,
|
||
|
|
"value" REAL NOT NULL,
|
||
|
|
"granularity" INTEGER NOT NULL
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "serverpod_health_metric_timestamp_idx" ON "serverpod_health_metric" ("timestamp", "serverId", "name", "granularity");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class LogEntry as table serverpod_log
|
||
|
|
--
|
||
|
|
CREATE TABLE "serverpod_log" (
|
||
|
|
"id" INTEGER PRIMARY KEY,
|
||
|
|
"sessionLogId" INTEGER NOT NULL,
|
||
|
|
"messageId" INTEGER,
|
||
|
|
"reference" TEXT,
|
||
|
|
"serverId" TEXT NOT NULL,
|
||
|
|
"time" INTEGER NOT NULL,
|
||
|
|
"logLevel" INTEGER NOT NULL,
|
||
|
|
"message" TEXT NOT NULL,
|
||
|
|
"error" TEXT,
|
||
|
|
"stackTrace" TEXT,
|
||
|
|
"order" INTEGER NOT NULL,
|
||
|
|
CONSTRAINT "serverpod_log_fk_0" FOREIGN KEY ("sessionLogId") REFERENCES "serverpod_session_log" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE INDEX "serverpod_log_sessionLogId_idx" ON "serverpod_log" ("sessionLogId", "order");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class MessageLogEntry as table serverpod_message_log
|
||
|
|
--
|
||
|
|
CREATE TABLE "serverpod_message_log" (
|
||
|
|
"id" INTEGER PRIMARY KEY,
|
||
|
|
"sessionLogId" INTEGER NOT NULL,
|
||
|
|
"serverId" TEXT NOT NULL,
|
||
|
|
"messageId" INTEGER NOT NULL,
|
||
|
|
"endpoint" TEXT NOT NULL,
|
||
|
|
"messageName" TEXT NOT NULL,
|
||
|
|
"duration" REAL NOT NULL,
|
||
|
|
"error" TEXT,
|
||
|
|
"stackTrace" TEXT,
|
||
|
|
"slow" INTEGER NOT NULL,
|
||
|
|
"order" INTEGER NOT NULL,
|
||
|
|
CONSTRAINT "serverpod_message_log_fk_0" FOREIGN KEY ("sessionLogId") REFERENCES "serverpod_session_log" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE INDEX "serverpod_message_log_sessionLogId_idx" ON "serverpod_message_log" ("sessionLogId", "order");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class MethodInfo as table serverpod_method
|
||
|
|
--
|
||
|
|
CREATE TABLE "serverpod_method" (
|
||
|
|
"id" INTEGER PRIMARY KEY,
|
||
|
|
"endpoint" TEXT NOT NULL,
|
||
|
|
"method" TEXT NOT NULL
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "serverpod_method_endpoint_method_idx" ON "serverpod_method" ("endpoint", "method");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class DatabaseMigrationVersion as table serverpod_migrations
|
||
|
|
--
|
||
|
|
CREATE TABLE "serverpod_migrations" (
|
||
|
|
"id" INTEGER PRIMARY KEY,
|
||
|
|
"module" TEXT NOT NULL,
|
||
|
|
"version" TEXT NOT NULL,
|
||
|
|
"timestamp" INTEGER
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "serverpod_migrations_ids" ON "serverpod_migrations" ("module");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class QueryLogEntry as table serverpod_query_log
|
||
|
|
--
|
||
|
|
CREATE TABLE "serverpod_query_log" (
|
||
|
|
"id" INTEGER PRIMARY KEY,
|
||
|
|
"serverId" TEXT NOT NULL,
|
||
|
|
"sessionLogId" INTEGER NOT NULL,
|
||
|
|
"messageId" INTEGER,
|
||
|
|
"query" TEXT NOT NULL,
|
||
|
|
"duration" REAL NOT NULL,
|
||
|
|
"numRows" INTEGER,
|
||
|
|
"error" TEXT,
|
||
|
|
"stackTrace" TEXT,
|
||
|
|
"slow" INTEGER NOT NULL,
|
||
|
|
"order" INTEGER NOT NULL,
|
||
|
|
CONSTRAINT "serverpod_query_log_fk_0" FOREIGN KEY ("sessionLogId") REFERENCES "serverpod_session_log" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE INDEX "serverpod_query_log_sessionLogId_idx" ON "serverpod_query_log" ("sessionLogId", "order");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class ReadWriteTestEntry as table serverpod_readwrite_test
|
||
|
|
--
|
||
|
|
CREATE TABLE "serverpod_readwrite_test" (
|
||
|
|
"id" INTEGER PRIMARY KEY,
|
||
|
|
"number" INTEGER NOT NULL
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class RuntimeSettings as table serverpod_runtime_settings
|
||
|
|
--
|
||
|
|
CREATE TABLE "serverpod_runtime_settings" (
|
||
|
|
"id" INTEGER PRIMARY KEY,
|
||
|
|
"logSettings" TEXT NOT NULL,
|
||
|
|
"logSettingsOverrides" TEXT NOT NULL,
|
||
|
|
"logServiceCalls" INTEGER NOT NULL,
|
||
|
|
"logMalformedCalls" INTEGER NOT NULL
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class SessionLogEntry as table serverpod_session_log
|
||
|
|
--
|
||
|
|
CREATE TABLE "serverpod_session_log" (
|
||
|
|
"id" INTEGER PRIMARY KEY,
|
||
|
|
"serverId" TEXT NOT NULL,
|
||
|
|
"time" INTEGER NOT NULL,
|
||
|
|
"module" TEXT,
|
||
|
|
"endpoint" TEXT,
|
||
|
|
"method" TEXT,
|
||
|
|
"duration" REAL,
|
||
|
|
"numQueries" INTEGER,
|
||
|
|
"slow" INTEGER,
|
||
|
|
"error" TEXT,
|
||
|
|
"stackTrace" TEXT,
|
||
|
|
"authenticatedUserId" INTEGER,
|
||
|
|
"userId" TEXT,
|
||
|
|
"isOpen" INTEGER,
|
||
|
|
"touched" INTEGER NOT NULL
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE INDEX "serverpod_session_log_serverid_idx" ON "serverpod_session_log" ("serverId");
|
||
|
|
CREATE INDEX "serverpod_session_log_time_idx" ON "serverpod_session_log" ("time");
|
||
|
|
CREATE INDEX "serverpod_session_log_touched_idx" ON "serverpod_session_log" ("touched");
|
||
|
|
CREATE INDEX "serverpod_session_log_isopen_idx" ON "serverpod_session_log" ("isOpen");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class RefreshToken as table serverpod_auth_core_jwt_refresh_token
|
||
|
|
--
|
||
|
|
CREATE TABLE "serverpod_auth_core_jwt_refresh_token" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"authUserId" BLOB NOT NULL,
|
||
|
|
"scopeNames" TEXT NOT NULL,
|
||
|
|
"extraClaims" TEXT,
|
||
|
|
"method" TEXT NOT NULL,
|
||
|
|
"fixedSecret" BLOB NOT NULL,
|
||
|
|
"rotatingSecretHash" TEXT NOT NULL,
|
||
|
|
"lastUpdatedAt" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsecond') * 1000 AS INTEGER)),
|
||
|
|
"createdAt" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsecond') * 1000 AS INTEGER)),
|
||
|
|
CONSTRAINT "serverpod_auth_core_jwt_refresh_token_fk_0" FOREIGN KEY ("authUserId") REFERENCES "serverpod_auth_core_user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE INDEX "serverpod_auth_core_jwt_refresh_token_last_updated_at" ON "serverpod_auth_core_jwt_refresh_token" ("lastUpdatedAt");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class UserProfile as table serverpod_auth_core_profile
|
||
|
|
--
|
||
|
|
CREATE TABLE "serverpod_auth_core_profile" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"authUserId" BLOB NOT NULL,
|
||
|
|
"userName" TEXT,
|
||
|
|
"fullName" TEXT,
|
||
|
|
"email" TEXT,
|
||
|
|
"createdAt" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsecond') * 1000 AS INTEGER)),
|
||
|
|
"imageId" BLOB,
|
||
|
|
CONSTRAINT "serverpod_auth_core_profile_fk_0" FOREIGN KEY ("authUserId") REFERENCES "serverpod_auth_core_user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||
|
|
CONSTRAINT "serverpod_auth_core_profile_fk_1" FOREIGN KEY ("imageId") REFERENCES "serverpod_auth_core_profile_image" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "serverpod_auth_profile_user_profile_email_auth_user_id" ON "serverpod_auth_core_profile" ("authUserId");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class UserProfileImage as table serverpod_auth_core_profile_image
|
||
|
|
--
|
||
|
|
CREATE TABLE "serverpod_auth_core_profile_image" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"userProfileId" BLOB NOT NULL,
|
||
|
|
"createdAt" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsecond') * 1000 AS INTEGER)),
|
||
|
|
"storageId" TEXT NOT NULL,
|
||
|
|
"path" TEXT NOT NULL,
|
||
|
|
"url" TEXT NOT NULL,
|
||
|
|
CONSTRAINT "serverpod_auth_core_profile_image_fk_0" FOREIGN KEY ("userProfileId") REFERENCES "serverpod_auth_core_profile" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class ServerSideSession as table serverpod_auth_core_session
|
||
|
|
--
|
||
|
|
CREATE TABLE "serverpod_auth_core_session" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"authUserId" BLOB NOT NULL,
|
||
|
|
"scopeNames" TEXT NOT NULL,
|
||
|
|
"createdAt" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsecond') * 1000 AS INTEGER)),
|
||
|
|
"lastUsedAt" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsecond') * 1000 AS INTEGER)),
|
||
|
|
"expiresAt" INTEGER,
|
||
|
|
"expireAfterUnusedFor" INTEGER,
|
||
|
|
"sessionKeyHash" BLOB NOT NULL,
|
||
|
|
"sessionKeySalt" BLOB NOT NULL,
|
||
|
|
"method" TEXT NOT NULL,
|
||
|
|
CONSTRAINT "serverpod_auth_core_session_fk_0" FOREIGN KEY ("authUserId") REFERENCES "serverpod_auth_core_user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class AuthUser as table serverpod_auth_core_user
|
||
|
|
--
|
||
|
|
CREATE TABLE "serverpod_auth_core_user" (
|
||
|
|
"id" BLOB PRIMARY KEY DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"createdAt" INTEGER NOT NULL,
|
||
|
|
"scopeNames" TEXT NOT NULL,
|
||
|
|
"blocked" INTEGER NOT NULL
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class CrdtDataAttemptedValue as table crdt_data_attempted_value
|
||
|
|
--
|
||
|
|
CREATE TABLE "crdt_data_attempted_value" (
|
||
|
|
"id" INTEGER PRIMARY KEY,
|
||
|
|
"fieldId" INTEGER NOT NULL,
|
||
|
|
"value" BLOB NOT NULL,
|
||
|
|
"projectionReason" INTEGER NOT NULL,
|
||
|
|
CONSTRAINT "crdt_data_attempted_value_fk_0" FOREIGN KEY ("fieldId") REFERENCES "crdt_data_fields" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "crdt_data_attempted_value__fieldId__unique_idx" ON "crdt_data_attempted_value" ("fieldId");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class CrdtDataField as table crdt_data_fields
|
||
|
|
--
|
||
|
|
CREATE TABLE "crdt_data_fields" (
|
||
|
|
"id" INTEGER PRIMARY KEY,
|
||
|
|
"hlcDatetime" INTEGER NOT NULL,
|
||
|
|
"hlcCounter" INTEGER NOT NULL,
|
||
|
|
"rowId" INTEGER NOT NULL,
|
||
|
|
"columnId" INTEGER NOT NULL,
|
||
|
|
"nodeId" INTEGER NOT NULL,
|
||
|
|
CONSTRAINT "crdt_data_fields_fk_0" FOREIGN KEY ("rowId") REFERENCES "crdt_data_rows" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||
|
|
CONSTRAINT "crdt_data_fields_fk_1" FOREIGN KEY ("columnId") REFERENCES "crdt_schema_columns" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||
|
|
CONSTRAINT "crdt_data_fields_fk_2" FOREIGN KEY ("nodeId") REFERENCES "crdt_nodes" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "crdt_data_fields_row_column_idx" ON "crdt_data_fields" ("rowId", "columnId");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class CrdtDataRow as table crdt_data_rows
|
||
|
|
--
|
||
|
|
CREATE TABLE "crdt_data_rows" (
|
||
|
|
"id" INTEGER PRIMARY KEY,
|
||
|
|
"hlcDatetime" INTEGER NOT NULL,
|
||
|
|
"hlcCounter" INTEGER NOT NULL,
|
||
|
|
"scopeId" INTEGER NOT NULL,
|
||
|
|
"tblId" INTEGER NOT NULL,
|
||
|
|
"uuidRowId" BLOB NOT NULL,
|
||
|
|
"nodeId" INTEGER NOT NULL,
|
||
|
|
"visibility" INTEGER NOT NULL DEFAULT (0),
|
||
|
|
CONSTRAINT "crdt_data_rows_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||
|
|
CONSTRAINT "crdt_data_rows_fk_1" FOREIGN KEY ("tblId") REFERENCES "crdt_schema_tables" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||
|
|
CONSTRAINT "crdt_data_rows_fk_2" FOREIGN KEY ("nodeId") REFERENCES "crdt_nodes" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "crdt_data_rows_scope_tbl_row_idx" ON "crdt_data_rows" ("scopeId", "tblId", "uuidRowId");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class CrdtDataDeleted as table crdt_data_tombstone
|
||
|
|
--
|
||
|
|
CREATE TABLE "crdt_data_tombstone" (
|
||
|
|
"id" INTEGER PRIMARY KEY,
|
||
|
|
"hlcDatetime" INTEGER NOT NULL,
|
||
|
|
"hlcCounter" INTEGER NOT NULL,
|
||
|
|
"rowId" INTEGER NOT NULL,
|
||
|
|
"nodeId" INTEGER NOT NULL,
|
||
|
|
"clFlag" INTEGER NOT NULL,
|
||
|
|
"reason" INTEGER NOT NULL,
|
||
|
|
CONSTRAINT "crdt_data_tombstone_fk_0" FOREIGN KEY ("rowId") REFERENCES "crdt_data_rows" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||
|
|
CONSTRAINT "crdt_data_tombstone_fk_1" FOREIGN KEY ("nodeId") REFERENCES "crdt_nodes" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "crdt_data_tombstone_row_idx" ON "crdt_data_tombstone" ("rowId");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class CrdtNode as table crdt_nodes
|
||
|
|
--
|
||
|
|
CREATE TABLE "crdt_nodes" (
|
||
|
|
"id" INTEGER PRIMARY KEY,
|
||
|
|
"uuidNodeId" BLOB NOT NULL DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"lastHlc" BLOB
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "crdt_nodes__uuidNodeId__unique_idx" ON "crdt_nodes" ("uuidNodeId");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class CrdtSchemaColumn as table crdt_schema_columns
|
||
|
|
--
|
||
|
|
CREATE TABLE "crdt_schema_columns" (
|
||
|
|
"id" INTEGER PRIMARY KEY,
|
||
|
|
"tblId" INTEGER NOT NULL,
|
||
|
|
"name" TEXT NOT NULL,
|
||
|
|
"columnType" TEXT NOT NULL,
|
||
|
|
"dartType" TEXT NOT NULL,
|
||
|
|
"isNullable" INTEGER NOT NULL,
|
||
|
|
CONSTRAINT "crdt_schema_columns_fk_0" FOREIGN KEY ("tblId") REFERENCES "crdt_schema_tables" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "crdt_schema_columns_table_column_idx" ON "crdt_schema_columns" ("tblId", "name");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class CrdtSchemaTable as table crdt_schema_tables
|
||
|
|
--
|
||
|
|
CREATE TABLE "crdt_schema_tables" (
|
||
|
|
"id" INTEGER PRIMARY KEY,
|
||
|
|
"name" TEXT NOT NULL
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "crdt_schema_tables__name__unique_idx" ON "crdt_schema_tables" ("name");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class CrdtScopeMember as table crdt_scope_members
|
||
|
|
--
|
||
|
|
CREATE TABLE "crdt_scope_members" (
|
||
|
|
"id" INTEGER PRIMARY KEY,
|
||
|
|
"scopeId" INTEGER NOT NULL,
|
||
|
|
"userUuid" BLOB NOT NULL,
|
||
|
|
"role" TEXT NOT NULL,
|
||
|
|
CONSTRAINT "crdt_scope_members_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "crdt_scope_member_unique_idx" ON "crdt_scope_members" ("userUuid", "scopeId");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class CrdtScopeNode as table crdt_scope_nodes
|
||
|
|
--
|
||
|
|
CREATE TABLE "crdt_scope_nodes" (
|
||
|
|
"id" INTEGER PRIMARY KEY,
|
||
|
|
"scopeId" INTEGER NOT NULL,
|
||
|
|
"nodeId" INTEGER NOT NULL,
|
||
|
|
"lastReceivedHlc" BLOB,
|
||
|
|
CONSTRAINT "crdt_scope_nodes_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||
|
|
CONSTRAINT "crdt_scope_nodes_fk_1" FOREIGN KEY ("nodeId") REFERENCES "crdt_nodes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "crdt_scope_node_unique_idx" ON "crdt_scope_nodes" ("scopeId", "nodeId");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class CrdtScope as table crdt_scopes
|
||
|
|
--
|
||
|
|
CREATE TABLE "crdt_scopes" (
|
||
|
|
"id" INTEGER PRIMARY KEY,
|
||
|
|
"uuidScopeId" BLOB NOT NULL DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
|
||
|
|
"currentNodeId" INTEGER,
|
||
|
|
CONSTRAINT "crdt_scopes_fk_0" FOREIGN KEY ("currentNodeId") REFERENCES "crdt_nodes" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "crdt_scopes__uuidScopeId__unique_idx" ON "crdt_scopes" ("uuidScopeId");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- Class CrdtSyncIntegrityViolation as table crdt_sync_integrity_violations
|
||
|
|
--
|
||
|
|
CREATE TABLE "crdt_sync_integrity_violations" (
|
||
|
|
"id" INTEGER PRIMARY KEY,
|
||
|
|
"type" TEXT NOT NULL,
|
||
|
|
"domainTableName" TEXT NOT NULL,
|
||
|
|
"uuidRowId" BLOB NOT NULL,
|
||
|
|
"ownerScopeUuid" BLOB,
|
||
|
|
"incomingScopeUuid" BLOB NOT NULL,
|
||
|
|
"operation" TEXT NOT NULL,
|
||
|
|
"uuidNodeId" BLOB,
|
||
|
|
"crdtDataRowId" INTEGER,
|
||
|
|
"hlcDatetime" INTEGER,
|
||
|
|
"hlcCounter" INTEGER,
|
||
|
|
"firstSeenAt" INTEGER NOT NULL,
|
||
|
|
"lastSeenAt" INTEGER NOT NULL,
|
||
|
|
"occurrences" INTEGER NOT NULL
|
||
|
|
) STRICT;
|
||
|
|
|
||
|
|
-- Indexes
|
||
|
|
CREATE UNIQUE INDEX "crdt_sync_integrity_violations_key_idx" ON "crdt_sync_integrity_violations" ("type", "operation", "domainTableName", "uuidRowId", "ownerScopeUuid", "incomingScopeUuid");
|
||
|
|
|
||
|
|
|
||
|
|
--
|
||
|
|
-- STORE COLUMN TYPES FOR MIGRATIONS
|
||
|
|
--
|
||
|
|
DROP TABLE IF EXISTS "serverpod_sqlite_schema";
|
||
|
|
|
||
|
|
CREATE TABLE "serverpod_sqlite_schema" (
|
||
|
|
"table_name" TEXT NOT NULL,
|
||
|
|
"column_name" TEXT NOT NULL,
|
||
|
|
"column_type" TEXT NOT NULL,
|
||
|
|
"column_vector_dimension" INTEGER,
|
||
|
|
PRIMARY KEY ("table_name", "column_name")
|
||
|
|
);
|
||
|
|
|
||
|
|
INSERT INTO "serverpod_sqlite_schema" VALUES
|
||
|
|
('address', 'id', 'uuid', NULL),
|
||
|
|
('address', 'inhabitantId', 'uuid', NULL),
|
||
|
|
('city', 'id', 'uuid', NULL),
|
||
|
|
('company', 'id', 'uuid', NULL),
|
||
|
|
('company', 'townId', 'uuid', NULL),
|
||
|
|
('fk_chain_cascade_middle', 'id', 'uuid', NULL),
|
||
|
|
('fk_chain_cascade_middle', 'rootId', 'uuid', NULL),
|
||
|
|
('fk_chain_middle_cascade_child', 'id', 'uuid', NULL),
|
||
|
|
('fk_chain_middle_cascade_child', 'restrictBlockerId', 'uuid', NULL),
|
||
|
|
('fk_chain_middle_set_null_child', 'id', 'uuid', NULL),
|
||
|
|
('fk_chain_middle_set_null_child', 'restrictBlockerId', 'uuid', NULL),
|
||
|
|
('fk_chain_restrict_blocker', 'id', 'uuid', NULL),
|
||
|
|
('fk_chain_restrict_blocker', 'cascadeMiddleId', 'uuid', NULL),
|
||
|
|
('fk_chain_root', 'id', 'uuid', NULL),
|
||
|
|
('fk_chain_set_null_cascade_child', 'id', 'uuid', NULL),
|
||
|
|
('fk_chain_set_null_cascade_child', 'setNullMiddleId', 'uuid', NULL),
|
||
|
|
('fk_chain_set_null_middle', 'id', 'uuid', NULL),
|
||
|
|
('fk_chain_set_null_middle', 'cascadeMiddleId', 'uuid', NULL),
|
||
|
|
('fk_chain_set_null_restrict_child', 'id', 'uuid', NULL),
|
||
|
|
('fk_chain_set_null_restrict_child', 'setNullMiddleId', 'uuid', NULL),
|
||
|
|
('fk_chain_set_null_set_null_child', 'id', 'uuid', NULL),
|
||
|
|
('fk_chain_set_null_set_null_child', 'setNullMiddleId', 'uuid', NULL),
|
||
|
|
('organization', 'id', 'uuid', NULL),
|
||
|
|
('organization', 'cityId', 'uuid', NULL),
|
||
|
|
('person', 'id', 'uuid', NULL),
|
||
|
|
('person', 'organizationId', 'uuid', NULL),
|
||
|
|
('person', 'oldCompanyId', 'uuid', NULL),
|
||
|
|
('person', 'cityId', 'uuid', NULL),
|
||
|
|
('required_set_null_child', 'id', 'uuid', NULL),
|
||
|
|
('required_set_null_child', 'parentId', 'uuid', NULL),
|
||
|
|
('restrict_child', 'id', 'uuid', NULL),
|
||
|
|
('restrict_child', 'parentId', 'uuid', NULL),
|
||
|
|
('town', 'id', 'uuid', NULL),
|
||
|
|
('town', 'cityId', 'uuid', NULL),
|
||
|
|
('town', 'mayorId', 'uuid', NULL),
|
||
|
|
('types', 'id', 'uuid', NULL),
|
||
|
|
('types', 'aBool', 'boolean', NULL),
|
||
|
|
('types', 'aDateTime', 'timestampWithoutTimeZone', NULL),
|
||
|
|
('types', 'optionalUuid', 'uuid', NULL),
|
||
|
|
('unique', 'id', 'uuid', NULL),
|
||
|
|
('unique_cascade_child', 'id', 'uuid', NULL),
|
||
|
|
('unique_cascade_child', 'parentId', 'uuid', NULL),
|
||
|
|
('unique_composite', 'id', 'uuid', NULL),
|
||
|
|
('unique_discriminator', 'id', 'uuid', NULL),
|
||
|
|
('unique_fk_pair', 'id', 'uuid', NULL),
|
||
|
|
('unique_fk_pair', 'leftId', 'uuid', NULL),
|
||
|
|
('unique_fk_pair', 'rightId', 'uuid', NULL),
|
||
|
|
('unique_mixed_fk', 'id', 'uuid', NULL),
|
||
|
|
('unique_mixed_fk', 'parentId', 'uuid', NULL),
|
||
|
|
('unique_no_release', 'id', 'uuid', NULL),
|
||
|
|
('unique_nullable', 'id', 'uuid', NULL),
|
||
|
|
('unique_overlapping', 'id', 'uuid', NULL),
|
||
|
|
('unique_set_null_child', 'id', 'uuid', NULL),
|
||
|
|
('unique_set_null_child', 'parentId', 'uuid', NULL),
|
||
|
|
('unique_uuid', 'id', 'uuid', NULL),
|
||
|
|
('unique_uuid', 'value', 'uuid', NULL),
|
||
|
|
('serverpod_cloud_storage', 'addedTime', 'timestampWithoutTimeZone', NULL),
|
||
|
|
('serverpod_cloud_storage', 'expiration', 'timestampWithoutTimeZone', NULL),
|
||
|
|
('serverpod_cloud_storage', 'verified', 'boolean', NULL),
|
||
|
|
('serverpod_cloud_storage_direct_download', 'expiration', 'timestampWithoutTimeZone', NULL),
|
||
|
|
('serverpod_cloud_storage_direct_upload', 'expiration', 'timestampWithoutTimeZone', NULL),
|
||
|
|
('serverpod_cloud_storage_direct_upload', 'preventOverwrite', 'boolean', NULL),
|
||
|
|
('serverpod_future_call', 'time', 'timestampWithoutTimeZone', NULL),
|
||
|
|
('serverpod_future_call', 'scheduling', 'json', NULL),
|
||
|
|
('serverpod_future_call_claim', 'lastHeartbeatTime', 'timestampWithoutTimeZone', NULL),
|
||
|
|
('serverpod_health_connection_info', 'timestamp', 'timestampWithoutTimeZone', NULL),
|
||
|
|
('serverpod_health_metric', 'timestamp', 'timestampWithoutTimeZone', NULL),
|
||
|
|
('serverpod_health_metric', 'isHealthy', 'boolean', NULL),
|
||
|
|
('serverpod_log', 'time', 'timestampWithoutTimeZone', NULL),
|
||
|
|
('serverpod_message_log', 'slow', 'boolean', NULL),
|
||
|
|
('serverpod_migrations', 'timestamp', 'timestampWithoutTimeZone', NULL),
|
||
|
|
('serverpod_query_log', 'slow', 'boolean', NULL),
|
||
|
|
('serverpod_runtime_settings', 'logSettings', 'json', NULL),
|
||
|
|
('serverpod_runtime_settings', 'logSettingsOverrides', 'json', NULL),
|
||
|
|
('serverpod_runtime_settings', 'logServiceCalls', 'boolean', NULL),
|
||
|
|
('serverpod_runtime_settings', 'logMalformedCalls', 'boolean', NULL),
|
||
|
|
('serverpod_session_log', 'time', 'timestampWithoutTimeZone', NULL),
|
||
|
|
('serverpod_session_log', 'slow', 'boolean', NULL),
|
||
|
|
('serverpod_session_log', 'isOpen', 'boolean', NULL),
|
||
|
|
('serverpod_session_log', 'touched', 'timestampWithoutTimeZone', NULL),
|
||
|
|
('serverpod_auth_core_jwt_refresh_token', 'id', 'uuid', NULL),
|
||
|
|
('serverpod_auth_core_jwt_refresh_token', 'authUserId', 'uuid', NULL),
|
||
|
|
('serverpod_auth_core_jwt_refresh_token', 'scopeNames', 'json', NULL),
|
||
|
|
('serverpod_auth_core_jwt_refresh_token', 'lastUpdatedAt', 'timestampWithoutTimeZone', NULL),
|
||
|
|
('serverpod_auth_core_jwt_refresh_token', 'createdAt', 'timestampWithoutTimeZone', NULL),
|
||
|
|
('serverpod_auth_core_profile', 'id', 'uuid', NULL),
|
||
|
|
('serverpod_auth_core_profile', 'authUserId', 'uuid', NULL),
|
||
|
|
('serverpod_auth_core_profile', 'createdAt', 'timestampWithoutTimeZone', NULL),
|
||
|
|
('serverpod_auth_core_profile', 'imageId', 'uuid', NULL),
|
||
|
|
('serverpod_auth_core_profile_image', 'id', 'uuid', NULL),
|
||
|
|
('serverpod_auth_core_profile_image', 'userProfileId', 'uuid', NULL),
|
||
|
|
('serverpod_auth_core_profile_image', 'createdAt', 'timestampWithoutTimeZone', NULL),
|
||
|
|
('serverpod_auth_core_session', 'id', 'uuid', NULL),
|
||
|
|
('serverpod_auth_core_session', 'authUserId', 'uuid', NULL),
|
||
|
|
('serverpod_auth_core_session', 'scopeNames', 'json', NULL),
|
||
|
|
('serverpod_auth_core_session', 'createdAt', 'timestampWithoutTimeZone', NULL),
|
||
|
|
('serverpod_auth_core_session', 'lastUsedAt', 'timestampWithoutTimeZone', NULL),
|
||
|
|
('serverpod_auth_core_session', 'expiresAt', 'timestampWithoutTimeZone', NULL),
|
||
|
|
('serverpod_auth_core_user', 'id', 'uuid', NULL),
|
||
|
|
('serverpod_auth_core_user', 'createdAt', 'timestampWithoutTimeZone', NULL),
|
||
|
|
('serverpod_auth_core_user', 'scopeNames', 'json', NULL),
|
||
|
|
('serverpod_auth_core_user', 'blocked', 'boolean', NULL),
|
||
|
|
('crdt_data_attempted_value', 'value', 'jsonb', NULL),
|
||
|
|
('crdt_data_fields', 'hlcDatetime', 'timestampWithoutTimeZone', NULL),
|
||
|
|
('crdt_data_rows', 'hlcDatetime', 'timestampWithoutTimeZone', NULL),
|
||
|
|
('crdt_data_rows', 'uuidRowId', 'uuid', NULL),
|
||
|
|
('crdt_data_tombstone', 'hlcDatetime', 'timestampWithoutTimeZone', NULL),
|
||
|
|
('crdt_nodes', 'uuidNodeId', 'uuid', NULL),
|
||
|
|
('crdt_nodes', 'lastHlc', 'jsonb', NULL),
|
||
|
|
('crdt_schema_columns', 'isNullable', 'boolean', NULL),
|
||
|
|
('crdt_scope_members', 'userUuid', 'uuid', NULL),
|
||
|
|
('crdt_scope_nodes', 'lastReceivedHlc', 'jsonb', NULL),
|
||
|
|
('crdt_scopes', 'uuidScopeId', 'uuid', NULL),
|
||
|
|
('crdt_sync_integrity_violations', 'uuidRowId', 'uuid', NULL),
|
||
|
|
('crdt_sync_integrity_violations', 'ownerScopeUuid', 'uuid', NULL),
|
||
|
|
('crdt_sync_integrity_violations', 'incomingScopeUuid', 'uuid', NULL),
|
||
|
|
('crdt_sync_integrity_violations', 'uuidNodeId', 'uuid', NULL),
|
||
|
|
('crdt_sync_integrity_violations', 'hlcDatetime', 'timestampWithoutTimeZone', NULL),
|
||
|
|
('crdt_sync_integrity_violations', 'firstSeenAt', 'timestampWithoutTimeZone', NULL),
|
||
|
|
('crdt_sync_integrity_violations', 'lastSeenAt', 'timestampWithoutTimeZone', NULL);
|
||
|
|
|
||
|
|
--
|
||
|
|
-- MIGRATION VERSION FOR serverpod_offline_sync_test
|
||
|
|
--
|
||
|
|
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
|
||
|
|
VALUES ('serverpod_offline_sync_test', '20260907165715131', (unixepoch('now', 'subsecond') * 1000))
|
||
|
|
ON CONFLICT ("module")
|
||
|
|
DO UPDATE SET "version" = '20260907165715131', "timestamp" = (unixepoch('now', 'subsecond') * 1000);
|
||
|
|
|
||
|
|
--
|
||
|
|
-- MIGRATION VERSION FOR serverpod
|
||
|
|
--
|
||
|
|
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
|
||
|
|
VALUES ('serverpod', '20260824182259319', (unixepoch('now', 'subsecond') * 1000))
|
||
|
|
ON CONFLICT ("module")
|
||
|
|
DO UPDATE SET "version" = '20260824182259319', "timestamp" = (unixepoch('now', 'subsecond') * 1000);
|
||
|
|
|
||
|
|
--
|
||
|
|
-- MIGRATION VERSION FOR serverpod_auth_core
|
||
|
|
--
|
||
|
|
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
|
||
|
|
VALUES ('serverpod_auth_core', '20260824182354731', (unixepoch('now', 'subsecond') * 1000))
|
||
|
|
ON CONFLICT ("module")
|
||
|
|
DO UPDATE SET "version" = '20260824182354731', "timestamp" = (unixepoch('now', 'subsecond') * 1000);
|
||
|
|
|
||
|
|
--
|
||
|
|
-- MIGRATION VERSION FOR serverpod_offline_sync
|
||
|
|
--
|
||
|
|
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
|
||
|
|
VALUES ('serverpod_offline_sync', '20260902195732182', (unixepoch('now', 'subsecond') * 1000))
|
||
|
|
ON CONFLICT ("module")
|
||
|
|
DO UPDATE SET "version" = '20260902195732182', "timestamp" = (unixepoch('now', 'subsecond') * 1000);
|
||
|
|
|
||
|
|
|
||
|
|
COMMIT;
|