1
0
Fork 0
mirror of synced 2024-08-05 05:11:43 +12:00

Making sure that columns get updated to allow nulls/disallow correctly, as well as making sure enums can be updated and autocolumn state can change.

This commit is contained in:
mike12345567 2024-06-07 16:57:33 +01:00
parent 74de806a37
commit a879b5814a

View file

@ -280,12 +280,29 @@ function copyExistingPropsOver(
utils.unreachable(existingColumnType)
}
// copy the BB schema in case of special props
if (shouldKeepSchema) {
const fetchedColumnDefinition: FieldSchema | undefined =
table.schema[key]
table.schema[key] = {
...existingTableSchema[key],
externalType:
existingTableSchema[key].externalType ||
table.schema[key]?.externalType,
autocolumn: !!fetchedColumnDefinition?.autocolumn,
} as FieldSchema
// check constraints which can be fetched from the DB (they could be updated)
if (fetchedColumnDefinition?.constraints) {
// inclusions are the enum values (select/options)
const fetchedInclusion = fetchedColumnDefinition.constraints.inclusion
const oldInclusion = table.schema[key].constraints?.inclusion
table.schema[key].constraints = {
...table.schema[key].constraints,
presence: !!fetchedColumnDefinition.constraints?.presence,
inclusion: fetchedInclusion?.length
? fetchedInclusion
: oldInclusion,
}
}
}
}