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:
Marcelo Mendonça Soares 2026-10-08 22:48:47 -03:00 • committed by GitHub
commit ee000e348c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 21728 additions and 51 deletions

View file

@ -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
}

View file

@ -16,6 +16,7 @@ part '20260914144112288/migration.dart';
part '20260914165608984/migration.dart';
part '20260930185557154/migration.dart';
part '20261007215503877/migration.dart';
part '20261008234516445/migration.dart';
/// Migration registry for the client-side database.
class MigrationRegistry {
@ -34,6 +35,7 @@ class MigrationRegistry {
_Migration20260914165608984(),
_Migration20260930185557154(),
_Migration20261007215503877(),
_Migration20261008234516445(),
];
/// List of all client-side database migration versions.

View file

@ -2124,6 +2124,23 @@ class Protocol extends _isd.DatabaseSerializationManager {
isUnique: true,
isPrimary: false,
),
_isd.IndexDefinition(
indexName: 'unique_set_default_child_name',
tableSpace: null,
elements: [
_isd.IndexElementDefinition(
type: _isd.IndexElementDefinitionType.column,
definition: 'spaceId',
),
_isd.IndexElementDefinition(
type: _isd.IndexElementDefinitionType.column,
definition: 'name',
),
],
type: 'btree',
isUnique: true,
isPrimary: false,
),
],
managed: true,
),