// Creates or modify (currently only datatype) a column for a given canyon register entity field
// Creates or modify (currently only datatype and nullability) a column for a given canyon register entity field
// Case when field contains a primary key annotation, and it's not already on database, add it to constrains_operations
// Case when field doesn't contains a primary key annotation, but there is one in the database column
// Case when field contains a foreign key annotation, and it's not already on database, add it to constraints_operations
// Will contain the table name (on index 0) and column name (on index 1) pointed to by the foreign key
// If entity foreign key is not equal to the one on database, a constrains_operations is added to delete it and add a new one.
// Case when field don't contains a foreign key annotation, but there is already one in the database column
/// Get the table metadata for a given entity name or his old entity name if the table was renamed.
.filter(|x| !x.contains("Annotation: ForeignKey")) // After here, we only have the "table" and the "column" attribute values
format!("ALTER TABLE \"{table_name}\" ALTER COLUMN \"{}\" DROP NOT NULL;", entity_field.field_name),
#[cfg(feature = "mssql")] ColumnOperation::DropNotNullBeforeDropColumn(table_name, column_name, column_datatype) =>
"ALTER TABLE {table_name} ALTER COLUMN {column_name} {column_datatype} NULL; DECLARE @tableName VARCHAR(MAX) = '{table_name}'
#[cfg(feature = "postgres")] ColumnOperation::AlterColumnAddIdentity(table_name, entity_field) => format!(
"ALTER TABLE \"{table_name}\" ALTER COLUMN \"{}\" ADD GENERATED ALWAYS AS IDENTITY;", entity_field.field_name
#[cfg(feature = "postgres")] ColumnOperation::AlterColumnDropIdentity(table_name, entity_field) => format!(
"SELECT setval(pg_get_serial_sequence('\"{table_name}\"', '{}'), max(\"{}\")) from \"{table_name}\";",