$schema =
clone $currentSchema;
// Mark all content type to be deleted, hopefully they will be redefined in the next step
foreach ($schema->
getTables() as $table) { if (strpos($table->
getName(), 's_custom_'
) === 0
) { $schema->
dropTable($table->
getName());
} } // Create all tables
foreach ($types as $type) { $myTable =
$schema->
createTable($type->
getTableName());
$myTable->
addColumn('id', 'integer',
['unsigned' => true, 'autoincrement' => true
]);
$myTable->
setPrimaryKey(['id'
]);
/** @var Field $field */
foreach ($type->
getFields() as $field) { $myTable->
addColumn($field->
getName(),
$field->
getType()::
getDbalType(),
['notnull' =>
$field->
isRequired()]);
} $myTable->
addColumn('created_at', 'datetime',
[]);
$myTable->
addColumn('updated_at', 'datetime',
[]);
}