XF 2.1 Get enum column types

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:
Code:
        $schema->alterTable('table', function($table) {
            $columnDef = $table->getColumnDefinition('column');
            $type = $columnDef['Type'];
            $newType = str_replace(",'foo'", ",'foo','bar'", $type);
            $table->changeColumn('column', $newType);
        });
However this looks fishy. Replacing strings doesn't look like proper way of doing it.

In XF/Install/Data/MySql.php I found this:
Code:
$table->addColumn('recipient_state', 'enum')->values(['active','deleted','deleted_ignored']);
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?
 
PHP:
$table->changeColumn('column_name_goes_here')->addValues(['new_possible_value_goes_here', 'or_maybe_even_more']);
 
Something went wrong. That query changed everything to upper case. Or is it normal?

edit: its normal. Collation is set to utf8mb4_general_ci
 
Last edited:
Top Bottom