fix: Author the column default an upsert writes for a null foreign key (#164)
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
This commit is contained in:
parent
4bf2359dda
commit
ee000e348c
6 changed files with 21728 additions and 51 deletions
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,68 @@
|
|||
{
|
||||
"__className__": "serverpod.DatabaseMigration",
|
||||
"actions": [
|
||||
{
|
||||
"__className__": "serverpod.DatabaseMigrationAction",
|
||||
"type": "alterTable",
|
||||
"alterTable": {
|
||||
"__className__": "serverpod.TableMigration",
|
||||
"name": "unique_set_default_child",
|
||||
"schema": "public",
|
||||
"addColumns": [],
|
||||
"deleteColumns": [],
|
||||
"modifyColumns": [],
|
||||
"addIndexes": [
|
||||
{
|
||||
"__className__": "serverpod.IndexDefinition",
|
||||
"indexName": "unique_set_default_child_name",
|
||||
"elements": [
|
||||
{
|
||||
"__className__": "serverpod.IndexElementDefinition",
|
||||
"type": 0,
|
||||
"definition": "spaceId"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.IndexElementDefinition",
|
||||
"type": 0,
|
||||
"definition": "name"
|
||||
}
|
||||
],
|
||||
"type": "btree",
|
||||
"isUnique": true,
|
||||
"isPrimary": false
|
||||
}
|
||||
],
|
||||
"deleteIndexes": [],
|
||||
"addForeignKeys": [],
|
||||
"deleteForeignKeys": [],
|
||||
"warnings": [
|
||||
{
|
||||
"__className__": "serverpod.DatabaseMigrationWarning",
|
||||
"type": "uniqueIndexCreated",
|
||||
"message": "Unique index \"unique_set_default_child_name\" is added to table \"unique_set_default_child\". If there are existing rows with duplicate values, this migration will fail.",
|
||||
"table": "unique_set_default_child",
|
||||
"columns": [
|
||||
"spaceId",
|
||||
"name"
|
||||
],
|
||||
"destrucive": false
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"warnings": [
|
||||
{
|
||||
"__className__": "serverpod.DatabaseMigrationWarning",
|
||||
"type": "uniqueIndexCreated",
|
||||
"message": "Unique index \"unique_set_default_child_name\" is added to table \"unique_set_default_child\". If there are existing rows with duplicate values, this migration will fail.",
|
||||
"table": "unique_set_default_child",
|
||||
"columns": [
|
||||
"spaceId",
|
||||
"name"
|
||||
],
|
||||
"destrucive": false
|
||||
}
|
||||
],
|
||||
"migrationApiVersion": 1
|
||||
}
|
||||
|
|
@ -0,0 +1,189 @@
|
|||
BEGIN;
|
||||
|
||||
--
|
||||
-- ACTION ALTER TABLE
|
||||
--
|
||||
CREATE UNIQUE INDEX "unique_set_default_child_name" ON "unique_set_default_child" ("spaceId", "name");
|
||||
|
||||
--
|
||||
-- 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_cascade_child', 'id', 'uuid', NULL),
|
||||
('required_cascade_child', 'parentId', 'uuid', NULL),
|
||||
('required_no_action_child', 'id', 'uuid', NULL),
|
||||
('required_no_action_child', 'parentId', 'uuid', NULL),
|
||||
('restrict_child', 'id', 'uuid', NULL),
|
||||
('restrict_child', 'parentId', 'uuid', NULL),
|
||||
('shared_child', 'id', 'uuid', NULL),
|
||||
('shared_child', 'parentId', 'uuid', NULL),
|
||||
('shared_parent', 'id', '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),
|
||||
('types', 'parentId', 'uuid', NULL),
|
||||
('types', 'jsonDocument', 'json', NULL),
|
||||
('types', 'jsonbDocument', 'jsonb', NULL),
|
||||
('types', 'jsonbNumbers', 'jsonb', NULL),
|
||||
('unique', 'id', 'uuid', NULL),
|
||||
('unique_cascade_child', 'id', 'uuid', NULL),
|
||||
('unique_cascade_child', 'parentId', 'uuid', NULL),
|
||||
('unique_cascade_reference', 'id', 'uuid', NULL),
|
||||
('unique_cascade_reference', '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_default_child', 'id', 'uuid', NULL),
|
||||
('unique_set_default_child', 'parentId', '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),
|
||||
('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);
|
||||
|
||||
--
|
||||
-- MIGRATION VERSION FOR serverpod_offline_sync_test
|
||||
--
|
||||
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
|
||||
VALUES ('serverpod_offline_sync_test', '20261008234516445', (unixepoch('now', 'subsecond') * 1000))
|
||||
ON CONFLICT ("module")
|
||||
DO UPDATE SET "version" = '20261008234516445', "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', '20260924105232991', (unixepoch('now', 'subsecond') * 1000))
|
||||
ON CONFLICT ("module")
|
||||
DO UPDATE SET "version" = '20260924105232991', "timestamp" = (unixepoch('now', 'subsecond') * 1000);
|
||||
|
||||
--
|
||||
-- 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);
|
||||
|
||||
|
||||
COMMIT;
|
||||
|
|
@ -16,3 +16,4 @@
|
|||
20260914165608984
|
||||
20260930185557154
|
||||
20261007215503877
|
||||
20261008234516445
|
||||
|
|
|
|||
Loading…
Reference in a new issue