Add space before replacements to avoid any issues with similar types

This commit is contained in:
mattbucci
2024-01-08 04:08:35 +00:00
parent 7471e353e9
commit 200dfaa0b2
2 changed files with 31 additions and 27 deletions

View File

@ -3,30 +3,32 @@
class AlterTableSQLRewriter extends AbstractSQLRewriter
{
private $stringReplacements = [
'bigint(20)' => 'bigint',
'bigint(10)' => 'int',
'int(11)' => 'int',
'tinytext' => 'text',
'mediumtext' => 'text',
'longtext' => 'text',
'unsigned' => '',
' bigint(40)' => ' bigint',
' bigint(20)' => ' bigint',
' bigint(10)' => ' int',
' int(11)' => ' int',
' int(10)' => ' int',
' tinytext' => ' text',
' mediumtext' => ' text',
' longtext' => ' text',
' unsigned' => ' ',
'gmt datetime NOT NULL default \'0000-00-00 00:00:00\'' => 'gmt timestamp NOT NULL DEFAULT timezone(\'gmt\'::text, now())',
'default \'0000-00-00 00:00:00\'' => 'DEFAULT now()',
'\'0000-00-00 00:00:00\'' => 'now()',
'datetime' => 'timestamp',
' datetime' => ' timestamp',
'DEFAULT CHARACTER SET utf8' => '',
// WP 2.7.1 compatibility
'int(4)' => 'smallint',
' int(4)' => ' smallint',
// For WPMU (starting with WP 3.2)
'tinyint(2)' => 'smallint',
'tinyint(1)' => 'smallint',
"enum('0','1')" => 'smallint',
'COLLATE utf8_general_ci' => '',
' tinyint(2)' => ' smallint',
' tinyint(1)' => ' smallint',
" enum('0','1')" => ' smallint',
' COLLATE utf8_general_ci' => ' ',
// For flash-album-gallery plugin
'tinyint' => 'smallint'
' tinyint' => ' smallint'
];
public function rewrite(): string

View File

@ -3,14 +3,16 @@
class CreateTableSQLRewriter extends AbstractSQLRewriter
{
private $stringReplacements = [
'bigint(20)' => 'bigint',
'bigint(10)' => 'int',
'int(11)' => 'int',
'int(1)' => 'smallint',
'tinytext' => 'text',
'mediumtext' => 'text',
'longtext' => 'text',
'unsigned' => '',
' bigint(40)' => ' bigint',
' bigint(20)' => ' bigint',
' bigint(10)' => ' int',
' int(11)' => ' int',
' int(10)' => ' int',
' int(1)' => ' smallint',
' tinytext' => ' text',
' mediumtext' => ' text',
' longtext' => ' text',
' unsigned' => ' ',
'gmt datetime NOT NULL default \'0000-00-00 00:00:00\'' => 'gmt timestamp NOT NULL DEFAULT timezone(\'gmt\'::text, now())',
'default \'0000-00-00 00:00:00\'' => 'DEFAULT now()',
'\'0000-00-00 00:00:00\'' => 'now()',
@ -19,17 +21,17 @@ class CreateTableSQLRewriter extends AbstractSQLRewriter
'DEFAULT CHARACTER SET utf8' => '',
// WP 2.7.1 compatibility
'int(4)' => 'smallint',
' int(4)' => ' smallint',
// For WPMU (starting with WP 3.2)
'tinyint(2)' => 'smallint',
'tinyint(1)' => 'smallint',
"enum('0','1')" => 'smallint',
' tinyint(2)' => ' smallint',
' tinyint(1)' => ' smallint',
" enum('0','1')" => ' smallint',
'COLLATE utf8mb4_unicode_520_ci' => '',
'COLLATE utf8_general_ci' => '',
// For flash-album-gallery plugin
'tinyint' => 'smallint'
' tinyint' => ' smallint'
];
public function rewrite(): string