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:
parent
74de806a37
commit
a879b5814a
|
@ -280,12 +280,29 @@ function copyExistingPropsOver(
|
||||||
utils.unreachable(existingColumnType)
|
utils.unreachable(existingColumnType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// copy the BB schema in case of special props
|
||||||
if (shouldKeepSchema) {
|
if (shouldKeepSchema) {
|
||||||
|
const fetchedColumnDefinition: FieldSchema | undefined =
|
||||||
|
table.schema[key]
|
||||||
table.schema[key] = {
|
table.schema[key] = {
|
||||||
...existingTableSchema[key],
|
...existingTableSchema[key],
|
||||||
externalType:
|
externalType:
|
||||||
existingTableSchema[key].externalType ||
|
existingTableSchema[key].externalType ||
|
||||||
table.schema[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,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue