Jake B.
Well-known member
In the SchemaManager there is a 'renameColumn' and 'changeColumn' function, but there doesn't seem to be a way to do both at the same time. In fact, I can't even do both within the same alterTable callback like this:
I just get this error:
However, if I split it into two separate alters it seems to work:
Just seems a bit convoluted, and there likely should be a way to do it all at once (unless I'm missing something and this is already possible)
PHP:
$schemaManager->alterTable('xf_table', function(\XF\Db\Schema\Alter $table) {
$table->renameColumn('old_column', 'new_column');
$table->changeColumn('new_column', 'bool')->setDefault(1);
});
I just get this error:
Column definition 'new_column' does not exist therefore it cannot be changed.
However, if I split it into two separate alters it seems to work:
PHP:
$schemaManager->alterTable('xf_table', function(\XF\Db\Schema\Alter $table) {
$table->renameColumn('old_column', 'new_column');
});
$schemaManager->alterTable('xf_table', function(\XF\Db\Schema\Alter $table) {
$table->changeColumn('new_column', 'bool')->setDefault(1);
});
Just seems a bit convoluted, and there likely should be a way to do it all at once (unless I'm missing something and this is already possible)