Arty
Well-known member
I want to add new entry to enum() column. To do that properly I want to get existing enum types and add new one to list.
My current code is like this:
However this looks fishy. Replacing strings doesn't look like proper way of doing it.
In XF/Install/Data/MySql.php I found this:
So that looks like proper way of doing it. But how can I get existing structure properly as array? Should I just parse string or is there a better way?
My current code is like this:
Code:
$schema->alterTable('table', function($table) {
$columnDef = $table->getColumnDefinition('column');
$type = $columnDef['Type'];
$newType = str_replace(",'foo'", ",'foo','bar'", $type);
$table->changeColumn('column', $newType);
});
In XF/Install/Data/MySql.php I found this:
Code:
$table->addColumn('recipient_state', 'enum')->values(['active','deleted','deleted_ignored']);