refactor!: Rename sync APIs and ownership spaces (#128)
This commit is contained in:
parent
4331daf661
commit
b89725f6ea
6 changed files with 43650 additions and 9417 deletions
2627
packages/serverpod_offline_sync_server/migrations/20260914143806119/definition.json
generated
Normal file
2627
packages/serverpod_offline_sync_server/migrations/20260914143806119/definition.json
generated
Normal file
File diff suppressed because it is too large
Load diff
535
packages/serverpod_offline_sync_server/migrations/20260914143806119/definition.sql
generated
Normal file
535
packages/serverpod_offline_sync_server/migrations/20260914143806119/definition.sql
generated
Normal file
|
|
@ -0,0 +1,535 @@
|
|||
BEGIN;
|
||||
|
||||
--
|
||||
-- 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,
|
||||
"spaceId" 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 ("spaceId") REFERENCES "offline_sync_spaces" ("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_space_tbl_row_idx" ON "crdt_data_rows" ("spaceId", "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 OfflineSyncIntegrityViolation as table offline_sync_integrity_violations
|
||||
--
|
||||
CREATE TABLE "offline_sync_integrity_violations" (
|
||||
"id" INTEGER PRIMARY KEY,
|
||||
"type" TEXT NOT NULL,
|
||||
"domainTableName" TEXT NOT NULL,
|
||||
"uuidRowId" BLOB NOT NULL,
|
||||
"ownerSpaceUuid" BLOB,
|
||||
"incomingSpaceUuid" 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 "offline_sync_integrity_violations_key_idx" ON "offline_sync_integrity_violations" ("type", "operation", "domainTableName", "uuidRowId", "ownerSpaceUuid", "incomingSpaceUuid");
|
||||
|
||||
|
||||
--
|
||||
-- Class OfflineSyncSpaceMember as table offline_sync_space_members
|
||||
--
|
||||
CREATE TABLE "offline_sync_space_members" (
|
||||
"id" INTEGER PRIMARY KEY,
|
||||
"spaceId" INTEGER NOT NULL,
|
||||
"userUuid" BLOB NOT NULL,
|
||||
"role" TEXT NOT NULL,
|
||||
CONSTRAINT "offline_sync_space_members_fk_0" FOREIGN KEY ("spaceId") REFERENCES "offline_sync_spaces" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
) STRICT;
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "offline_sync_space_member_unique_idx" ON "offline_sync_space_members" ("userUuid", "spaceId");
|
||||
|
||||
|
||||
--
|
||||
-- Class OfflineSyncSpaceNode as table offline_sync_space_nodes
|
||||
--
|
||||
CREATE TABLE "offline_sync_space_nodes" (
|
||||
"id" INTEGER PRIMARY KEY,
|
||||
"spaceId" INTEGER NOT NULL,
|
||||
"nodeId" INTEGER NOT NULL,
|
||||
"lastReceivedHlc" BLOB,
|
||||
CONSTRAINT "offline_sync_space_nodes_fk_0" FOREIGN KEY ("spaceId") REFERENCES "offline_sync_spaces" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||||
CONSTRAINT "offline_sync_space_nodes_fk_1" FOREIGN KEY ("nodeId") REFERENCES "crdt_nodes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
) STRICT;
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "offline_sync_space_node_unique_idx" ON "offline_sync_space_nodes" ("spaceId", "nodeId");
|
||||
|
||||
|
||||
--
|
||||
-- Class OfflineSyncSpace as table offline_sync_spaces
|
||||
--
|
||||
CREATE TABLE "offline_sync_spaces" (
|
||||
"id" INTEGER PRIMARY KEY,
|
||||
"uuidSpaceId" 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 "offline_sync_spaces_fk_0" FOREIGN KEY ("currentNodeId") REFERENCES "crdt_nodes" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
) STRICT;
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "offline_sync_spaces__uuidSpaceId__unique_idx" ON "offline_sync_spaces" ("uuidSpaceId");
|
||||
|
||||
|
||||
--
|
||||
-- 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");
|
||||
|
||||
|
||||
--
|
||||
-- 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
|
||||
('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),
|
||||
('offline_sync_integrity_violations', 'uuidRowId', 'uuid', NULL),
|
||||
('offline_sync_integrity_violations', 'ownerSpaceUuid', 'uuid', NULL),
|
||||
('offline_sync_integrity_violations', 'incomingSpaceUuid', 'uuid', NULL),
|
||||
('offline_sync_integrity_violations', 'uuidNodeId', 'uuid', NULL),
|
||||
('offline_sync_integrity_violations', 'hlcDatetime', 'timestampWithoutTimeZone', NULL),
|
||||
('offline_sync_integrity_violations', 'firstSeenAt', 'timestampWithoutTimeZone', NULL),
|
||||
('offline_sync_integrity_violations', 'lastSeenAt', 'timestampWithoutTimeZone', NULL),
|
||||
('offline_sync_space_members', 'userUuid', 'uuid', NULL),
|
||||
('offline_sync_space_nodes', 'lastReceivedHlc', 'jsonb', NULL),
|
||||
('offline_sync_spaces', 'uuidSpaceId', '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);
|
||||
|
||||
--
|
||||
-- MIGRATION VERSION FOR serverpod_offline_sync
|
||||
--
|
||||
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
|
||||
VALUES ('serverpod_offline_sync', '20260914143806119', (unixepoch('now', 'subsecond') * 1000))
|
||||
ON CONFLICT ("module")
|
||||
DO UPDATE SET "version" = '20260914143806119', "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);
|
||||
|
||||
|
||||
COMMIT;
|
||||
1073
packages/serverpod_offline_sync_server/migrations/20260914143806119/definition_project.json
generated
Normal file
1073
packages/serverpod_offline_sync_server/migrations/20260914143806119/definition_project.json
generated
Normal file
File diff suppressed because it is too large
Load diff
670
packages/serverpod_offline_sync_server/migrations/20260914143806119/migration.json
generated
Normal file
670
packages/serverpod_offline_sync_server/migrations/20260914143806119/migration.json
generated
Normal file
|
|
@ -0,0 +1,670 @@
|
|||
{
|
||||
"__className__": "serverpod.DatabaseMigration",
|
||||
"actions": [
|
||||
{
|
||||
"__className__": "serverpod.DatabaseMigrationAction",
|
||||
"type": "deleteTable",
|
||||
"deleteTable": "crdt_sync_integrity_violations"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.DatabaseMigrationAction",
|
||||
"type": "deleteTable",
|
||||
"deleteTable": "crdt_scopes"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.DatabaseMigrationAction",
|
||||
"type": "deleteTable",
|
||||
"deleteTable": "crdt_scope_nodes"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.DatabaseMigrationAction",
|
||||
"type": "deleteTable",
|
||||
"deleteTable": "crdt_scope_members"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.DatabaseMigrationAction",
|
||||
"type": "deleteTable",
|
||||
"deleteTable": "crdt_data_rows"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.DatabaseMigrationAction",
|
||||
"type": "createTable",
|
||||
"createTable": {
|
||||
"__className__": "serverpod.TableDefinition",
|
||||
"name": "crdt_data_rows",
|
||||
"dartName": "CrdtDataRow",
|
||||
"module": "serverpod_offline_sync",
|
||||
"schema": "public",
|
||||
"columns": [
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "id",
|
||||
"fieldName": "id",
|
||||
"columnType": 6,
|
||||
"isNullable": false,
|
||||
"columnDefault": "serial",
|
||||
"dartType": "int?"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "hlcDatetime",
|
||||
"fieldName": "hlcDatetime",
|
||||
"columnType": 4,
|
||||
"isNullable": false,
|
||||
"dartType": "DateTime"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "hlcCounter",
|
||||
"fieldName": "hlcCounter",
|
||||
"columnType": 6,
|
||||
"isNullable": false,
|
||||
"dartType": "int"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "spaceId",
|
||||
"fieldName": "spaceId",
|
||||
"columnType": 6,
|
||||
"isNullable": false,
|
||||
"dartType": "int"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "tblId",
|
||||
"fieldName": "tblId",
|
||||
"columnType": 6,
|
||||
"isNullable": false,
|
||||
"dartType": "int"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "uuidRowId",
|
||||
"fieldName": "uuidRowId",
|
||||
"columnType": 7,
|
||||
"isNullable": false,
|
||||
"dartType": "UuidValue"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "nodeId",
|
||||
"fieldName": "nodeId",
|
||||
"columnType": 6,
|
||||
"isNullable": false,
|
||||
"dartType": "int"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "visibility",
|
||||
"fieldName": "visibility",
|
||||
"columnType": 6,
|
||||
"isNullable": false,
|
||||
"columnDefault": "0",
|
||||
"dartType": "serverpod_offline_sync:CrdtDataRowVisibility"
|
||||
}
|
||||
],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"__className__": "serverpod.ForeignKeyDefinition",
|
||||
"constraintName": "crdt_data_rows_fk_0",
|
||||
"columns": [
|
||||
"spaceId"
|
||||
],
|
||||
"referenceTable": "offline_sync_spaces",
|
||||
"referenceTableSchema": "public",
|
||||
"referenceColumns": [
|
||||
"id"
|
||||
],
|
||||
"onUpdate": 3,
|
||||
"onDelete": 4
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ForeignKeyDefinition",
|
||||
"constraintName": "crdt_data_rows_fk_1",
|
||||
"columns": [
|
||||
"tblId"
|
||||
],
|
||||
"referenceTable": "crdt_schema_tables",
|
||||
"referenceTableSchema": "public",
|
||||
"referenceColumns": [
|
||||
"id"
|
||||
],
|
||||
"onUpdate": 3,
|
||||
"onDelete": 4
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ForeignKeyDefinition",
|
||||
"constraintName": "crdt_data_rows_fk_2",
|
||||
"columns": [
|
||||
"nodeId"
|
||||
],
|
||||
"referenceTable": "crdt_nodes",
|
||||
"referenceTableSchema": "public",
|
||||
"referenceColumns": [
|
||||
"id"
|
||||
],
|
||||
"onUpdate": 3,
|
||||
"onDelete": 3
|
||||
}
|
||||
],
|
||||
"indexes": [
|
||||
{
|
||||
"__className__": "serverpod.IndexDefinition",
|
||||
"indexName": "crdt_data_rows_space_tbl_row_idx",
|
||||
"elements": [
|
||||
{
|
||||
"__className__": "serverpod.IndexElementDefinition",
|
||||
"type": 0,
|
||||
"definition": "spaceId"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.IndexElementDefinition",
|
||||
"type": 0,
|
||||
"definition": "tblId"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.IndexElementDefinition",
|
||||
"type": 0,
|
||||
"definition": "uuidRowId"
|
||||
}
|
||||
],
|
||||
"type": "btree",
|
||||
"isUnique": true,
|
||||
"isPrimary": false
|
||||
}
|
||||
],
|
||||
"managed": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.DatabaseMigrationAction",
|
||||
"type": "createTable",
|
||||
"createTable": {
|
||||
"__className__": "serverpod.TableDefinition",
|
||||
"name": "offline_sync_integrity_violations",
|
||||
"dartName": "OfflineSyncIntegrityViolation",
|
||||
"module": "serverpod_offline_sync",
|
||||
"schema": "public",
|
||||
"columns": [
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "id",
|
||||
"fieldName": "id",
|
||||
"columnType": 6,
|
||||
"isNullable": false,
|
||||
"columnDefault": "serial",
|
||||
"dartType": "int?"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "type",
|
||||
"fieldName": "type",
|
||||
"columnType": 0,
|
||||
"isNullable": false,
|
||||
"dartType": "serverpod_offline_sync:OfflineSyncViolationType"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "domainTableName",
|
||||
"fieldName": "domainTableName",
|
||||
"columnType": 0,
|
||||
"isNullable": false,
|
||||
"dartType": "String"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "uuidRowId",
|
||||
"fieldName": "uuidRowId",
|
||||
"columnType": 7,
|
||||
"isNullable": false,
|
||||
"dartType": "UuidValue"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "ownerSpaceUuid",
|
||||
"fieldName": "ownerSpaceUuid",
|
||||
"columnType": 7,
|
||||
"isNullable": true,
|
||||
"dartType": "UuidValue?"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "incomingSpaceUuid",
|
||||
"fieldName": "incomingSpaceUuid",
|
||||
"columnType": 7,
|
||||
"isNullable": false,
|
||||
"dartType": "UuidValue"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "operation",
|
||||
"fieldName": "operation",
|
||||
"columnType": 0,
|
||||
"isNullable": false,
|
||||
"dartType": "serverpod_offline_sync:OfflineSyncViolationOperation"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "uuidNodeId",
|
||||
"fieldName": "uuidNodeId",
|
||||
"columnType": 7,
|
||||
"isNullable": true,
|
||||
"dartType": "UuidValue?"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "crdtDataRowId",
|
||||
"fieldName": "crdtDataRowId",
|
||||
"columnType": 6,
|
||||
"isNullable": true,
|
||||
"dartType": "int?"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "hlcDatetime",
|
||||
"fieldName": "hlcDatetime",
|
||||
"columnType": 4,
|
||||
"isNullable": true,
|
||||
"dartType": "DateTime?"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "hlcCounter",
|
||||
"fieldName": "hlcCounter",
|
||||
"columnType": 6,
|
||||
"isNullable": true,
|
||||
"dartType": "int?"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "firstSeenAt",
|
||||
"fieldName": "firstSeenAt",
|
||||
"columnType": 4,
|
||||
"isNullable": false,
|
||||
"dartType": "DateTime"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "lastSeenAt",
|
||||
"fieldName": "lastSeenAt",
|
||||
"columnType": 4,
|
||||
"isNullable": false,
|
||||
"dartType": "DateTime"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "occurrences",
|
||||
"fieldName": "occurrences",
|
||||
"columnType": 6,
|
||||
"isNullable": false,
|
||||
"dartType": "int"
|
||||
}
|
||||
],
|
||||
"foreignKeys": [],
|
||||
"indexes": [
|
||||
{
|
||||
"__className__": "serverpod.IndexDefinition",
|
||||
"indexName": "offline_sync_integrity_violations_key_idx",
|
||||
"elements": [
|
||||
{
|
||||
"__className__": "serverpod.IndexElementDefinition",
|
||||
"type": 0,
|
||||
"definition": "type"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.IndexElementDefinition",
|
||||
"type": 0,
|
||||
"definition": "operation"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.IndexElementDefinition",
|
||||
"type": 0,
|
||||
"definition": "domainTableName"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.IndexElementDefinition",
|
||||
"type": 0,
|
||||
"definition": "uuidRowId"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.IndexElementDefinition",
|
||||
"type": 0,
|
||||
"definition": "ownerSpaceUuid"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.IndexElementDefinition",
|
||||
"type": 0,
|
||||
"definition": "incomingSpaceUuid"
|
||||
}
|
||||
],
|
||||
"type": "btree",
|
||||
"isUnique": true,
|
||||
"isPrimary": false
|
||||
}
|
||||
],
|
||||
"managed": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.DatabaseMigrationAction",
|
||||
"type": "createTable",
|
||||
"createTable": {
|
||||
"__className__": "serverpod.TableDefinition",
|
||||
"name": "offline_sync_space_members",
|
||||
"dartName": "OfflineSyncSpaceMember",
|
||||
"module": "serverpod_offline_sync",
|
||||
"schema": "public",
|
||||
"columns": [
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "id",
|
||||
"fieldName": "id",
|
||||
"columnType": 6,
|
||||
"isNullable": false,
|
||||
"columnDefault": "serial",
|
||||
"dartType": "int?"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "spaceId",
|
||||
"fieldName": "spaceId",
|
||||
"columnType": 6,
|
||||
"isNullable": false,
|
||||
"dartType": "int"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "userUuid",
|
||||
"fieldName": "userUuid",
|
||||
"columnType": 7,
|
||||
"isNullable": false,
|
||||
"dartType": "UuidValue"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "role",
|
||||
"fieldName": "role",
|
||||
"columnType": 0,
|
||||
"isNullable": false,
|
||||
"dartType": "serverpod_offline_sync:OfflineSyncSpaceRole"
|
||||
}
|
||||
],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"__className__": "serverpod.ForeignKeyDefinition",
|
||||
"constraintName": "offline_sync_space_members_fk_0",
|
||||
"columns": [
|
||||
"spaceId"
|
||||
],
|
||||
"referenceTable": "offline_sync_spaces",
|
||||
"referenceTableSchema": "public",
|
||||
"referenceColumns": [
|
||||
"id"
|
||||
],
|
||||
"onUpdate": 3,
|
||||
"onDelete": 4
|
||||
}
|
||||
],
|
||||
"indexes": [
|
||||
{
|
||||
"__className__": "serverpod.IndexDefinition",
|
||||
"indexName": "offline_sync_space_member_unique_idx",
|
||||
"elements": [
|
||||
{
|
||||
"__className__": "serverpod.IndexElementDefinition",
|
||||
"type": 0,
|
||||
"definition": "userUuid"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.IndexElementDefinition",
|
||||
"type": 0,
|
||||
"definition": "spaceId"
|
||||
}
|
||||
],
|
||||
"type": "btree",
|
||||
"isUnique": true,
|
||||
"isPrimary": false
|
||||
}
|
||||
],
|
||||
"managed": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.DatabaseMigrationAction",
|
||||
"type": "createTable",
|
||||
"createTable": {
|
||||
"__className__": "serverpod.TableDefinition",
|
||||
"name": "offline_sync_space_nodes",
|
||||
"dartName": "OfflineSyncSpaceNode",
|
||||
"module": "serverpod_offline_sync",
|
||||
"schema": "public",
|
||||
"columns": [
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "id",
|
||||
"fieldName": "id",
|
||||
"columnType": 6,
|
||||
"isNullable": false,
|
||||
"columnDefault": "serial",
|
||||
"dartType": "int?"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "spaceId",
|
||||
"fieldName": "spaceId",
|
||||
"columnType": 6,
|
||||
"isNullable": false,
|
||||
"dartType": "int"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "nodeId",
|
||||
"fieldName": "nodeId",
|
||||
"columnType": 6,
|
||||
"isNullable": false,
|
||||
"dartType": "int"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "lastReceivedHlc",
|
||||
"fieldName": "lastReceivedHlc",
|
||||
"columnType": 14,
|
||||
"isNullable": true,
|
||||
"dartType": "package:serverpod_offline_sync/serverpod_offline_sync.dart:Hlc?"
|
||||
}
|
||||
],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"__className__": "serverpod.ForeignKeyDefinition",
|
||||
"constraintName": "offline_sync_space_nodes_fk_0",
|
||||
"columns": [
|
||||
"spaceId"
|
||||
],
|
||||
"referenceTable": "offline_sync_spaces",
|
||||
"referenceTableSchema": "public",
|
||||
"referenceColumns": [
|
||||
"id"
|
||||
],
|
||||
"onUpdate": 3,
|
||||
"onDelete": 4
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ForeignKeyDefinition",
|
||||
"constraintName": "offline_sync_space_nodes_fk_1",
|
||||
"columns": [
|
||||
"nodeId"
|
||||
],
|
||||
"referenceTable": "crdt_nodes",
|
||||
"referenceTableSchema": "public",
|
||||
"referenceColumns": [
|
||||
"id"
|
||||
],
|
||||
"onUpdate": 3,
|
||||
"onDelete": 4
|
||||
}
|
||||
],
|
||||
"indexes": [
|
||||
{
|
||||
"__className__": "serverpod.IndexDefinition",
|
||||
"indexName": "offline_sync_space_node_unique_idx",
|
||||
"elements": [
|
||||
{
|
||||
"__className__": "serverpod.IndexElementDefinition",
|
||||
"type": 0,
|
||||
"definition": "spaceId"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.IndexElementDefinition",
|
||||
"type": 0,
|
||||
"definition": "nodeId"
|
||||
}
|
||||
],
|
||||
"type": "btree",
|
||||
"isUnique": true,
|
||||
"isPrimary": false
|
||||
}
|
||||
],
|
||||
"managed": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.DatabaseMigrationAction",
|
||||
"type": "createTable",
|
||||
"createTable": {
|
||||
"__className__": "serverpod.TableDefinition",
|
||||
"name": "offline_sync_spaces",
|
||||
"dartName": "OfflineSyncSpace",
|
||||
"module": "serverpod_offline_sync",
|
||||
"schema": "public",
|
||||
"columns": [
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "id",
|
||||
"fieldName": "id",
|
||||
"columnType": 6,
|
||||
"isNullable": false,
|
||||
"columnDefault": "serial",
|
||||
"dartType": "int?"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "uuidSpaceId",
|
||||
"fieldName": "uuidSpaceId",
|
||||
"columnType": 7,
|
||||
"isNullable": false,
|
||||
"columnDefault": "random_v7",
|
||||
"dartType": "UuidValue"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "currentNodeId",
|
||||
"fieldName": "currentNodeId",
|
||||
"columnType": 6,
|
||||
"isNullable": true,
|
||||
"dartType": "int?"
|
||||
}
|
||||
],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"__className__": "serverpod.ForeignKeyDefinition",
|
||||
"constraintName": "offline_sync_spaces_fk_0",
|
||||
"columns": [
|
||||
"currentNodeId"
|
||||
],
|
||||
"referenceTable": "crdt_nodes",
|
||||
"referenceTableSchema": "public",
|
||||
"referenceColumns": [
|
||||
"id"
|
||||
],
|
||||
"onUpdate": 3,
|
||||
"onDelete": 3
|
||||
}
|
||||
],
|
||||
"indexes": [
|
||||
{
|
||||
"__className__": "serverpod.IndexDefinition",
|
||||
"indexName": "offline_sync_spaces__uuidSpaceId__unique_idx",
|
||||
"elements": [
|
||||
{
|
||||
"__className__": "serverpod.IndexElementDefinition",
|
||||
"type": 0,
|
||||
"definition": "uuidSpaceId"
|
||||
}
|
||||
],
|
||||
"type": "btree",
|
||||
"isUnique": true,
|
||||
"isPrimary": false
|
||||
}
|
||||
],
|
||||
"managed": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"warnings": [
|
||||
{
|
||||
"__className__": "serverpod.DatabaseMigrationWarning",
|
||||
"type": "tableDropped",
|
||||
"message": "Table \"crdt_sync_integrity_violations\" will be dropped.",
|
||||
"table": "crdt_sync_integrity_violations",
|
||||
"columns": [],
|
||||
"destrucive": true
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.DatabaseMigrationWarning",
|
||||
"type": "tableDropped",
|
||||
"message": "Table \"crdt_scopes\" will be dropped.",
|
||||
"table": "crdt_scopes",
|
||||
"columns": [],
|
||||
"destrucive": true
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.DatabaseMigrationWarning",
|
||||
"type": "tableDropped",
|
||||
"message": "Table \"crdt_scope_nodes\" will be dropped.",
|
||||
"table": "crdt_scope_nodes",
|
||||
"columns": [],
|
||||
"destrucive": true
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.DatabaseMigrationWarning",
|
||||
"type": "tableDropped",
|
||||
"message": "Table \"crdt_scope_members\" will be dropped.",
|
||||
"table": "crdt_scope_members",
|
||||
"columns": [],
|
||||
"destrucive": true
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.DatabaseMigrationWarning",
|
||||
"type": "columnDropped",
|
||||
"message": "Column \"scopeId\" of table \"crdt_data_rows\" will be dropped.",
|
||||
"table": "crdt_data_rows",
|
||||
"columns": [
|
||||
"scopeId"
|
||||
],
|
||||
"destrucive": true
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.DatabaseMigrationWarning",
|
||||
"type": "uniqueIndexCreated",
|
||||
"message": "Unique index \"crdt_data_rows_space_tbl_row_idx\" is added to table \"crdt_data_rows\". If there are existing rows with duplicate values, this migration will fail.",
|
||||
"table": "crdt_data_rows",
|
||||
"columns": [
|
||||
"spaceId",
|
||||
"tblId",
|
||||
"uuidRowId"
|
||||
],
|
||||
"destrucive": false
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.DatabaseMigrationWarning",
|
||||
"type": "tableDropped",
|
||||
"message": "One or more columns are added to table \"crdt_data_rows\" which cannot be added in a table migration. The complete table will be deleted and recreated.",
|
||||
"table": "crdt_data_rows",
|
||||
"columns": [
|
||||
"spaceId"
|
||||
],
|
||||
"destrucive": true
|
||||
}
|
||||
],
|
||||
"migrationApiVersion": 1
|
||||
}
|
||||
187
packages/serverpod_offline_sync_server/migrations/20260914143806119/migration.sql
generated
Normal file
187
packages/serverpod_offline_sync_server/migrations/20260914143806119/migration.sql
generated
Normal file
|
|
@ -0,0 +1,187 @@
|
|||
BEGIN;
|
||||
|
||||
--
|
||||
-- ACTION DROP TABLE
|
||||
--
|
||||
DROP TABLE "crdt_sync_integrity_violations";
|
||||
|
||||
--
|
||||
-- ACTION DROP TABLE
|
||||
--
|
||||
DROP TABLE "crdt_scopes";
|
||||
|
||||
--
|
||||
-- ACTION DROP TABLE
|
||||
--
|
||||
DROP TABLE "crdt_scope_nodes";
|
||||
|
||||
--
|
||||
-- ACTION DROP TABLE
|
||||
--
|
||||
DROP TABLE "crdt_scope_members";
|
||||
|
||||
--
|
||||
-- ACTION DROP TABLE
|
||||
--
|
||||
DROP TABLE "crdt_data_rows";
|
||||
|
||||
--
|
||||
-- ACTION CREATE TABLE
|
||||
--
|
||||
CREATE TABLE "crdt_data_rows" (
|
||||
"id" INTEGER PRIMARY KEY,
|
||||
"hlcDatetime" INTEGER NOT NULL,
|
||||
"hlcCounter" INTEGER NOT NULL,
|
||||
"spaceId" 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 ("spaceId") REFERENCES "offline_sync_spaces" ("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_space_tbl_row_idx" ON "crdt_data_rows" ("spaceId", "tblId", "uuidRowId");
|
||||
|
||||
--
|
||||
-- ACTION CREATE TABLE
|
||||
--
|
||||
CREATE TABLE "offline_sync_integrity_violations" (
|
||||
"id" INTEGER PRIMARY KEY,
|
||||
"type" TEXT NOT NULL,
|
||||
"domainTableName" TEXT NOT NULL,
|
||||
"uuidRowId" BLOB NOT NULL,
|
||||
"ownerSpaceUuid" BLOB,
|
||||
"incomingSpaceUuid" 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 "offline_sync_integrity_violations_key_idx" ON "offline_sync_integrity_violations" ("type", "operation", "domainTableName", "uuidRowId", "ownerSpaceUuid", "incomingSpaceUuid");
|
||||
|
||||
--
|
||||
-- ACTION CREATE TABLE
|
||||
--
|
||||
CREATE TABLE "offline_sync_space_members" (
|
||||
"id" INTEGER PRIMARY KEY,
|
||||
"spaceId" INTEGER NOT NULL,
|
||||
"userUuid" BLOB NOT NULL,
|
||||
"role" TEXT NOT NULL,
|
||||
CONSTRAINT "offline_sync_space_members_fk_0" FOREIGN KEY ("spaceId") REFERENCES "offline_sync_spaces" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
) STRICT;
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "offline_sync_space_member_unique_idx" ON "offline_sync_space_members" ("userUuid", "spaceId");
|
||||
|
||||
--
|
||||
-- ACTION CREATE TABLE
|
||||
--
|
||||
CREATE TABLE "offline_sync_space_nodes" (
|
||||
"id" INTEGER PRIMARY KEY,
|
||||
"spaceId" INTEGER NOT NULL,
|
||||
"nodeId" INTEGER NOT NULL,
|
||||
"lastReceivedHlc" BLOB,
|
||||
CONSTRAINT "offline_sync_space_nodes_fk_0" FOREIGN KEY ("spaceId") REFERENCES "offline_sync_spaces" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||||
CONSTRAINT "offline_sync_space_nodes_fk_1" FOREIGN KEY ("nodeId") REFERENCES "crdt_nodes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
) STRICT;
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "offline_sync_space_node_unique_idx" ON "offline_sync_space_nodes" ("spaceId", "nodeId");
|
||||
|
||||
--
|
||||
-- ACTION CREATE TABLE
|
||||
--
|
||||
CREATE TABLE "offline_sync_spaces" (
|
||||
"id" INTEGER PRIMARY KEY,
|
||||
"uuidSpaceId" 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 "offline_sync_spaces_fk_0" FOREIGN KEY ("currentNodeId") REFERENCES "crdt_nodes" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
) STRICT;
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "offline_sync_spaces__uuidSpaceId__unique_idx" ON "offline_sync_spaces" ("uuidSpaceId");
|
||||
|
||||
--
|
||||
-- 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
|
||||
('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),
|
||||
('offline_sync_integrity_violations', 'uuidRowId', 'uuid', NULL),
|
||||
('offline_sync_integrity_violations', 'ownerSpaceUuid', 'uuid', NULL),
|
||||
('offline_sync_integrity_violations', 'incomingSpaceUuid', 'uuid', NULL),
|
||||
('offline_sync_integrity_violations', 'uuidNodeId', 'uuid', NULL),
|
||||
('offline_sync_integrity_violations', 'hlcDatetime', 'timestampWithoutTimeZone', NULL),
|
||||
('offline_sync_integrity_violations', 'firstSeenAt', 'timestampWithoutTimeZone', NULL),
|
||||
('offline_sync_integrity_violations', 'lastSeenAt', 'timestampWithoutTimeZone', NULL),
|
||||
('offline_sync_space_members', 'userUuid', 'uuid', NULL),
|
||||
('offline_sync_space_nodes', 'lastReceivedHlc', 'jsonb', NULL),
|
||||
('offline_sync_spaces', 'uuidSpaceId', '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);
|
||||
|
||||
--
|
||||
-- MIGRATION VERSION FOR serverpod_offline_sync
|
||||
--
|
||||
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
|
||||
VALUES ('serverpod_offline_sync', '20260914143806119', (unixepoch('now', 'subsecond') * 1000))
|
||||
ON CONFLICT ("module")
|
||||
DO UPDATE SET "version" = '20260914143806119', "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);
|
||||
|
||||
|
||||
COMMIT;
|
||||
|
|
@ -8,3 +8,4 @@
|
|||
20260831202217145
|
||||
20260902184216091
|
||||
20260902195732182
|
||||
20260914143806119
|
||||
|
|
|
|||
Loading…
Reference in a new issue