-
Notifications
You must be signed in to change notification settings - Fork 267
Description
Note: I haven't tested this in 3.0, but at a glance the relevant code looks the same.
When using $smcFunc['db_change_column'], if the old type has a size but the new type doesn't, the old type will be automatically appended.
For example, if changing from VARCHAR(255) to TEXT, the resulting query will have TEXT(255).
That one will execute, but changing from a TINYINT to an ENUM, like in the test script below, will result in a syntax error in the SQL.
Standalone test script for 2.1 (put in the same directory as SSI.php):
<?php
require_once(dirname(__FILE__) . '/SSI.php');
db_extend('packages');
$smcFunc['db_select_db']($db_name);
$smcFunc['db_create_table'](
'test',
[
[
'name' => 'id',
'type' => 'int',
'unsigned' => true,
'null' => false,
'auto' => true,
],
[
'name' => 'some_value',
'type' => 'tinyint',
'unsigned' => true,
'default' => 0,
'null' => false,
],
],
[
[
'type' => 'primary',
'columns' => ['id'],
]
]
);
$smcFunc['db_change_column'](
'test',
'some_value',
[
'type' => 'ENUM(\'1\', \'2\', \'3\')',
'null' => false,
'drop_default' => true,
]
);
// Results in:
// ALTER TABLE test
// CHANGE COLUMN `some_value` `some_value` enum('1', '2', '3')(3) NOT NULL Reactions are currently unavailable