diff --git a/config/app.example.php b/config/app.example.php index 7a83dd3f2..3fc952b06 100644 --- a/config/app.example.php +++ b/config/app.example.php @@ -6,7 +6,8 @@ return [ 'Migrations' => [ - 'unsigned_primary_keys' => null, - 'column_null_default' => null, + 'unsigned_primary_keys' => null, // Default false + 'unsigned_ints' => null, // Default false, make sure this is aligned with the above config + 'column_null_default' => null, // Default false ], ]; diff --git a/docs/en/index.rst b/docs/en/index.rst index 0eff6a92b..5db4fe1a1 100644 --- a/docs/en/index.rst +++ b/docs/en/index.rst @@ -43,6 +43,12 @@ your application in your **config/app.php** file as explained in the `Database Configuration section `__. +Upgrading from 4.x +================== + +If you are upgrading from Migrations 4.x, please see the :doc:`upgrading` guide +for breaking changes and migration steps. + Overview ======== @@ -841,6 +847,7 @@ Feature Flags Migrations offers a few feature flags for compatibility. These features are disabled by default but can be enabled if required: * ``unsigned_primary_keys``: Should Migrations create primary keys as unsigned integers? (default: ``false``) +* ``unsigned_ints``: Should Migrations create all integer columns as unsigned? (default: ``false``) * ``column_null_default``: Should Migrations create columns as null by default? (default: ``false``) * ``add_timestamps_use_datetime``: Should Migrations use ``DATETIME`` type columns for the columns added by ``addTimestamps()``. @@ -849,9 +856,18 @@ Set them via Configure to enable (e.g. in ``config/app.php``):: 'Migrations' => [ 'unsigned_primary_keys' => true, + 'unsigned_ints' => true, 'column_null_default' => true, ], +.. note:: + + The ``unsigned_primary_keys`` and ``unsigned_ints`` options only affect MySQL databases. + When generating migrations with ``bake migration_snapshot`` or ``bake migration_diff``, + the ``signed`` attribute will only be included in the output for unsigned columns + (as ``'signed' => false``). Signed is the default for integer columns in MySQL, so + ``'signed' => true`` is never output. + Skipping the ``schema.lock`` file generation ============================================ diff --git a/docs/en/upgrading.rst b/docs/en/upgrading.rst new file mode 100644 index 000000000..23ab2e113 --- /dev/null +++ b/docs/en/upgrading.rst @@ -0,0 +1,140 @@ +Upgrading from 4.x to 5.x +######################### + +Migrations 5.x includes significant changes from 4.x. This guide outlines +the breaking changes and what you need to update when upgrading. + +Requirements +============ + +- **PHP 8.2+** is now required (was PHP 8.1+) +- **CakePHP 5.3+** is now required +- **Phinx has been removed** - The builtin backend is now the only supported backend + +If you were already using the builtin backend in 4.x (introduced in 4.3, default in 4.4), +the upgrade should be straightforward. See :doc:`upgrading-to-builtin-backend` for more +details on API differences between the phinx and builtin backends. + +Command Changes +=============== + +The phinx wrapper commands have been removed. The new command structure is: + +Migrations +---------- + +The migration commands remain unchanged: + +.. code-block:: bash + + bin/cake migrations migrate + bin/cake migrations rollback + bin/cake migrations status + bin/cake migrations mark_migrated + bin/cake migrations dump + +Seeds +----- + +Seed commands have changed: + +.. code-block:: bash + + # 4.x # 5.x + bin/cake migrations seed bin/cake seeds run + bin/cake migrations seed --seed X bin/cake seeds run X + +The new seed commands are: + +- ``bin/cake seeds run`` - Run seed classes +- ``bin/cake seeds run SeedName`` - Run a specific seed +- ``bin/cake seeds status`` - Show seed execution status +- ``bin/cake seeds reset`` - Reset seed execution tracking + +Maintaining Backward Compatibility +---------------------------------- + +If you need to maintain the old ``migrations seed`` command for existing scripts or +CI/CD pipelines, you can add command aliases in your ``src/Application.php``:: + + public function console(CommandCollection $commands): CommandCollection + { + $commands = $this->addConsoleCommands($commands); + + // Add backward compatibility alias + $commands->add('migrations seed', \Migrations\Command\SeedCommand::class); + + return $commands; + } + +Removed Classes and Namespaces +============================== + +The following have been removed in 5.x: + +- ``Migrations\Command\Phinx\*`` - All phinx wrapper commands +- ``Migrations\Command\MigrationsCommand`` - Use ``bin/cake migrations`` entry point +- ``Migrations\Command\MigrationsSeedCommand`` - Use ``bin/cake seeds run`` +- ``Migrations\Command\MigrationsCacheBuildCommand`` - Schema cache is managed differently +- ``Migrations\Command\MigrationsCacheClearCommand`` - Schema cache is managed differently +- ``Migrations\Command\MigrationsCreateCommand`` - Use ``bin/cake bake migration`` + +If you have code that directly references any of these classes, you will need to update it. + +API Changes +=========== + +Adapter Query Results +--------------------- + +If your migrations use ``AdapterInterface::query()`` to fetch rows, the return type has +changed from a phinx result to ``Cake\Database\StatementInterface``:: + + // 4.x (phinx) + $stmt = $this->getAdapter()->query('SELECT * FROM articles'); + $rows = $stmt->fetchAll(); + $row = $stmt->fetch(); + + // 5.x (builtin) + $stmt = $this->getAdapter()->query('SELECT * FROM articles'); + $rows = $stmt->fetchAll('assoc'); + $row = $stmt->fetch('assoc'); + +New Features in 5.x +=================== + +5.x includes several new features: + +Seed Tracking +------------- + +Seeds are now tracked in a ``cake_seeds`` table by default, preventing accidental re-runs. +Use ``--force`` to run a seed again, or ``bin/cake seeds reset`` to clear tracking. +See :doc:`seeding` for more details. + +Check Constraints +----------------- + +Support for database check constraints via ``addCheckConstraint()``. +See :doc:`writing-migrations` for usage details. + +MySQL ALTER Options +------------------- + +Support for ``ALGORITHM`` and ``LOCK`` options on MySQL ALTER TABLE operations, +allowing control over how MySQL performs schema changes. + +insertOrSkip() for Seeds +------------------------ + +New ``insertOrSkip()`` method for seeds to insert records only if they don't already exist, +making seeds more idempotent. + +Migration File Compatibility +============================ + +Your existing migration files should work without changes in most cases. The builtin backend +provides the same API as phinx for common operations. + +If you encounter issues with existing migrations, please report them at +https://github.com/cakephp/migrations/issues diff --git a/src/Command/BakeMigrationDiffCommand.php b/src/Command/BakeMigrationDiffCommand.php index a788e00c0..06a3c72cb 100644 --- a/src/Command/BakeMigrationDiffCommand.php +++ b/src/Command/BakeMigrationDiffCommand.php @@ -290,14 +290,10 @@ protected function getColumns(): void } } + // Only convert unsigned to signed if it actually changed if (isset($changedAttributes['unsigned'])) { $changedAttributes['signed'] = !$changedAttributes['unsigned']; unset($changedAttributes['unsigned']); - } else { - // badish hack - if (isset($column['unsigned']) && $column['unsigned'] === true) { - $changedAttributes['signed'] = false; - } } // For decimal columns, handle CakePHP schema -> migration attribute mapping diff --git a/src/Db/Adapter/MysqlAdapter.php b/src/Db/Adapter/MysqlAdapter.php index c01bce6ff..346408d0e 100644 --- a/src/Db/Adapter/MysqlAdapter.php +++ b/src/Db/Adapter/MysqlAdapter.php @@ -609,9 +609,8 @@ public function getColumns(string $tableName): array ->setScale($record['precision'] ?? null) ->setComment($record['comment']); - if ($record['unsigned'] ?? false) { - $column->setSigned(!$record['unsigned']); - } + // Always set unsigned property based on unsigned flag + $column->setUnsigned($record['unsigned'] ?? false); if ($record['autoIncrement'] ?? false) { $column->setIdentity(true); } diff --git a/src/Db/Table/Column.php b/src/Db/Table/Column.php index 73aaaf020..a16585f9e 100644 --- a/src/Db/Table/Column.php +++ b/src/Db/Table/Column.php @@ -18,6 +18,26 @@ /** * This object is based loosely on: https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/Table.html. + * + * ## Configuration + * + * The following configuration options can be set in your application's config: + * + * - `Migrations.unsigned_primary_keys` (bool): When true, identity columns default to unsigned. + * Default: false + * + * - `Migrations.unsigned_ints` (bool): When true, all integer columns default to unsigned. + * Default: false + * + * Example configuration in config/app.php: + * ```php + * 'Migrations' => [ + * 'unsigned_primary_keys' => true, + * 'unsigned_ints' => true, + * ] + * ``` + * + * Note: Explicitly calling setUnsigned() or setSigned() on a column will override these defaults. */ class Column extends DatabaseColumn { @@ -493,6 +513,63 @@ public function getComment(): ?string return $this->comment; } + /** + * Gets whether field should be unsigned. + * + * Checks configuration options to determine unsigned behavior: + * - If explicitly set via setUnsigned/setSigned, uses that value + * - If identity column and Migrations.unsigned_primary_keys is true, returns true + * - If integer type and Migrations.unsigned_ints is true, returns true + * - Otherwise defaults to false (signed) + * + * @return bool + */ + public function getUnsigned(): bool + { + // If explicitly set, use that value + if ($this->unsigned !== null) { + return $this->unsigned; + } + + $integerTypes = [ + self::INTEGER, + self::BIGINTEGER, + self::SMALLINTEGER, + self::TINYINTEGER, + ]; + + // Only apply configuration to integer types + if (!in_array($this->type, $integerTypes, true)) { + return false; + } + + // Check if this is a primary key/identity column + if ($this->identity && Configure::read('Migrations.unsigned_primary_keys')) { + return true; + } + + // Check general integer configuration + if (Configure::read('Migrations.unsigned_ints')) { + return true; + } + + // Default to signed for backward compatibility + return false; + } + + /** + * Sets whether field should be unsigned. + * + * @param bool $unsigned Unsigned + * @return $this + */ + public function setUnsigned(bool $unsigned) + { + $this->unsigned = $unsigned; + + return $this; + } + /** * Sets whether field should be signed. * @@ -515,18 +592,7 @@ public function setSigned(bool $signed) */ public function getSigned(): bool { - return $this->unsigned === null ? true : !$this->unsigned; - } - - /** - * Should the column be signed? - * - * @return bool - * @deprecated 5.0 Use isUnsigned() instead. - */ - public function isSigned(): bool - { - return $this->getSigned(); + return !$this->isUnsigned(); } /** @@ -826,7 +892,7 @@ public function toArray(): array 'null' => $this->getNull(), 'default' => $default, 'generated' => $this->getGenerated(), - 'unsigned' => !$this->getSigned(), + 'unsigned' => $this->getUnsigned(), 'onUpdate' => $this->getUpdate(), 'collate' => $this->getCollation(), 'precision' => $precision, diff --git a/src/View/Helper/MigrationHelper.php b/src/View/Helper/MigrationHelper.php index f6dd991c7..0547c30d4 100644 --- a/src/View/Helper/MigrationHelper.php +++ b/src/View/Helper/MigrationHelper.php @@ -406,6 +406,10 @@ public function getColumnOption(array $options): array if (!$isMysql) { unset($columnOptions['signed']); + } elseif (isset($columnOptions['signed']) && $columnOptions['signed'] === true) { + // Remove 'signed' => true since signed is the default for integer columns + // Only output explicit 'signed' => false for unsigned columns + unset($columnOptions['signed']); } if (($isMysql || $isSqlserver) && !empty($columnOptions['collate'])) { @@ -530,6 +534,10 @@ public function attributes(TableSchemaInterface|string $table, string $column): $isMysql = $connection->getDriver() instanceof Mysql; if (!$isMysql) { unset($attributes['signed']); + } elseif (isset($attributes['signed']) && $attributes['signed'] === true) { + // Remove 'signed' => true since signed is now the default for integer columns + // Only output explicit 'signed' => false for unsigned columns + unset($attributes['signed']); } $defaultCollation = $tableSchema->getOptions()['collation'] ?? null; diff --git a/tests/TestCase/Command/BakeMigrationDiffCommandTest.php b/tests/TestCase/Command/BakeMigrationDiffCommandTest.php index 3f3f483a0..2dc4d388a 100644 --- a/tests/TestCase/Command/BakeMigrationDiffCommandTest.php +++ b/tests/TestCase/Command/BakeMigrationDiffCommandTest.php @@ -233,6 +233,9 @@ public function testBakingDiff() { $this->skipIf(!env('DB_URL_COMPARE')); + Configure::write('Migrations.unsigned_primary_keys', true); + Configure::write('Migrations.unsigned_ints', true); + $this->runDiffBakingTest('Default'); } diff --git a/tests/TestCase/Db/Table/ColumnTest.php b/tests/TestCase/Db/Table/ColumnTest.php index 9db0c746d..0652149f3 100644 --- a/tests/TestCase/Db/Table/ColumnTest.php +++ b/tests/TestCase/Db/Table/ColumnTest.php @@ -8,12 +8,20 @@ use Cake\Database\ValueBinder; use Migrations\Db\Literal; use Migrations\Db\Table\Column; -use PHPUnit\Framework\Attributes\RunInSeparateProcess; use PHPUnit\Framework\TestCase; use RuntimeException; class ColumnTest extends TestCase { + protected function tearDown(): void + { + parent::tearDown(); + // Restore bootstrap defaults + Configure::write('Migrations.unsigned_primary_keys', true); + Configure::write('Migrations.column_null_default', true); + Configure::delete('Migrations.unsigned_ints'); + } + public function testNullConstructorParameter() { $column = new Column(name: 'title'); @@ -51,7 +59,6 @@ public function testSetOptionsIdentity() $this->assertTrue($column->isIdentity()); } - #[RunInSeparateProcess] public function testColumnNullFeatureFlag() { $column = new Column(); @@ -72,4 +79,200 @@ public function testToArrayDefaultLiteralValue(): void $this->assertInstanceOf(QueryExpression::class, $result['default']); $this->assertEquals('CURRENT_TIMESTAMP', $result['default']->sql(new ValueBinder())); } + + public function testIntegerColumnDefaultsToSigned(): void + { + $column = new Column(); + $column->setName('user_id')->setType('integer'); + + $this->assertFalse($column->isUnsigned()); + $this->assertTrue($column->isSigned()); + $this->assertFalse($column->getUnsigned()); + } + + public function testBigIntegerColumnDefaultsToSigned(): void + { + $column = new Column(); + $column->setName('big_id')->setType('biginteger'); + + $this->assertFalse($column->isUnsigned()); + $this->assertTrue($column->isSigned()); + $this->assertFalse($column->getUnsigned()); + } + + public function testSmallIntegerColumnDefaultsToSigned(): void + { + $column = new Column(); + $column->setName('small_id')->setType('smallinteger'); + + $this->assertFalse($column->isUnsigned()); + $this->assertTrue($column->isSigned()); + $this->assertFalse($column->getUnsigned()); + } + + public function testTinyIntegerColumnDefaultsToSigned(): void + { + $column = new Column(); + $column->setName('tiny_id')->setType('tinyinteger'); + + $this->assertFalse($column->isUnsigned()); + $this->assertTrue($column->isSigned()); + $this->assertFalse($column->getUnsigned()); + } + + public function testNonIntegerColumnDoesNotDefaultToUnsigned(): void + { + $stringColumn = new Column(); + $stringColumn->setName('name')->setType('string'); + $this->assertFalse($stringColumn->getUnsigned()); + $this->assertFalse($stringColumn->isUnsigned()); + + $dateColumn = new Column(); + $dateColumn->setName('created')->setType('datetime'); + $this->assertFalse($dateColumn->getUnsigned()); + $this->assertFalse($dateColumn->isUnsigned()); + + $decimalColumn = new Column(); + $decimalColumn->setName('price')->setType('decimal'); + $this->assertFalse($decimalColumn->getUnsigned()); + $this->assertFalse($decimalColumn->isUnsigned()); + } + + public function testExplicitSignedOverridesDefault(): void + { + $column = new Column(); + $column->setName('counter')->setType('integer')->setSigned(true); + + $this->assertFalse($column->isUnsigned()); + $this->assertTrue($column->isSigned()); + $this->assertFalse($column->getUnsigned()); + } + + public function testExplicitUnsignedIsPreserved(): void + { + $column = new Column(); + $column->setName('age')->setType('integer')->setUnsigned(true); + + $this->assertTrue($column->isUnsigned()); + $this->assertFalse($column->isSigned()); + $this->assertTrue($column->getUnsigned()); + } + + public function testToArrayReturnsFalseForIntegersByDefault(): void + { + $column = new Column(); + $column->setName('user_id')->setType('integer'); + + $result = $column->toArray(); + // getUnsigned() returns false for integer types by default (signed) + $this->assertFalse($result['unsigned']); + } + + public function testToArrayReturnsFalseForNonIntegerTypes(): void + { + $column = new Column(); + $column->setName('title')->setType('string'); + + $result = $column->toArray(); + $this->assertFalse($result['unsigned']); + } + + public function testToArrayRespectsExplicitSigned(): void + { + $column = new Column(); + $column->setName('offset')->setType('integer')->setSigned(true); + + $result = $column->toArray(); + $this->assertFalse($result['unsigned']); + } + + public function testUnsignedIntsConfiguration(): void + { + // Without configuration, integers default to signed + Configure::delete('Migrations.unsigned_ints'); + $column = new Column(); + $column->setName('count')->setType('integer'); + $this->assertFalse($column->isUnsigned()); + $this->assertTrue($column->isSigned()); + + // With configuration enabled, integers default to unsigned + Configure::write('Migrations.unsigned_ints', true); + $column = new Column(); + $column->setName('count')->setType('integer'); + $this->assertTrue($column->isUnsigned()); + $this->assertFalse($column->isSigned()); + + // Explicit signed overrides configuration + $column = new Column(); + $column->setName('offset')->setType('integer')->setSigned(true); + $this->assertFalse($column->isUnsigned()); + $this->assertTrue($column->isSigned()); + } + + public function testUnsignedPrimaryKeysConfiguration(): void + { + // Without configuration, identity columns default to signed + Configure::delete('Migrations.unsigned_primary_keys'); + $column = new Column(); + $column->setName('id')->setType('integer')->setIdentity(true); + $this->assertFalse($column->isUnsigned()); + $this->assertTrue($column->isSigned()); + + // With configuration enabled, identity columns default to unsigned + Configure::write('Migrations.unsigned_primary_keys', true); + $column = new Column(); + $column->setName('id')->setType('integer')->setIdentity(true); + $this->assertTrue($column->isUnsigned()); + $this->assertFalse($column->isSigned()); + + // Non-identity columns are not affected by unsigned_primary_keys + $column = new Column(); + $column->setName('user_id')->setType('integer'); + $this->assertFalse($column->isUnsigned()); + + // Explicit signed overrides configuration + $column = new Column(); + $column->setName('id')->setType('integer')->setIdentity(true)->setSigned(true); + $this->assertFalse($column->isUnsigned()); + $this->assertTrue($column->isSigned()); + } + + public function testBothUnsignedConfigurationsWork(): void + { + Configure::write('Migrations.unsigned_primary_keys', true); + Configure::write('Migrations.unsigned_ints', true); + + // Identity columns use unsigned_primary_keys configuration + $identityColumn = new Column(); + $identityColumn->setName('id')->setType('integer')->setIdentity(true); + $this->assertTrue($identityColumn->isUnsigned()); + + // Regular integer columns use unsigned_ints configuration + $intColumn = new Column(); + $intColumn->setName('count')->setType('integer'); + $this->assertTrue($intColumn->isUnsigned()); + + // Non-integer columns are not affected + $stringColumn = new Column(); + $stringColumn->setName('name')->setType('string'); + $this->assertFalse($stringColumn->isUnsigned()); + } + + public function testUnsignedConfigurationDoesNotAffectNonIntegerTypes(): void + { + Configure::write('Migrations.unsigned_ints', true); + Configure::write('Migrations.unsigned_primary_keys', true); + + $stringColumn = new Column(); + $stringColumn->setName('name')->setType('string'); + $this->assertFalse($stringColumn->isUnsigned()); + + $dateColumn = new Column(); + $dateColumn->setName('created')->setType('datetime'); + $this->assertFalse($dateColumn->isUnsigned()); + + $decimalColumn = new Column(); + $decimalColumn->setName('price')->setType('decimal'); + $this->assertFalse($decimalColumn->isUnsigned()); + } } diff --git a/tests/TestCase/View/Helper/MigrationHelperTest.php b/tests/TestCase/View/Helper/MigrationHelperTest.php index 0b26b9347..42a4d0083 100644 --- a/tests/TestCase/View/Helper/MigrationHelperTest.php +++ b/tests/TestCase/View/Helper/MigrationHelperTest.php @@ -20,10 +20,15 @@ use Cake\TestSuite\TestCase; use Cake\View\View; use Migrations\View\Helper\MigrationHelper; +use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses; /** * Tests the ConfigurationTrait + * + * Note: This test must run in a separate process because adapter tests earlier + * in the test suite drop and recreate the database, destroying the schema. */ +#[RunTestsInSeparateProcesses] class MigrationHelperTest extends TestCase { /** diff --git a/tests/comparisons/Diff/addRemove/the_diff_add_remove_mysql.php b/tests/comparisons/Diff/addRemove/the_diff_add_remove_mysql.php index d2da6226a..a6dd8bf6a 100644 --- a/tests/comparisons/Diff/addRemove/the_diff_add_remove_mysql.php +++ b/tests/comparisons/Diff/addRemove/the_diff_add_remove_mysql.php @@ -23,7 +23,6 @@ public function up(): void 'length' => null, 'limit' => null, 'null' => false, - 'signed' => true, ]) ->update(); diff --git a/tests/comparisons/Diff/decimalChange/mysql/the_diff_decimal_change_mysql.php b/tests/comparisons/Diff/decimalChange/mysql/the_diff_decimal_change_mysql.php index a64755d93..a32449e17 100644 --- a/tests/comparisons/Diff/decimalChange/mysql/the_diff_decimal_change_mysql.php +++ b/tests/comparisons/Diff/decimalChange/mysql/the_diff_decimal_change_mysql.php @@ -22,7 +22,6 @@ public function up(): void 'length' => null, 'limit' => null, 'null' => false, - 'signed' => false, ]) ->changeColumn('amount', 'decimal', [ 'default' => null, diff --git a/tests/comparisons/Diff/default/schema-dump-test_comparisons_mysql.lock b/tests/comparisons/Diff/default/schema-dump-test_comparisons_mysql.lock index 0cc5d0bb4..10092ee02 100644 Binary files a/tests/comparisons/Diff/default/schema-dump-test_comparisons_mysql.lock and b/tests/comparisons/Diff/default/schema-dump-test_comparisons_mysql.lock differ diff --git a/tests/comparisons/Diff/default/the_diff_default_mysql.php b/tests/comparisons/Diff/default/the_diff_default_mysql.php index 12d791c46..a889d9e7c 100644 --- a/tests/comparisons/Diff/default/the_diff_default_mysql.php +++ b/tests/comparisons/Diff/default/the_diff_default_mysql.php @@ -29,7 +29,6 @@ public function up(): void 'length' => null, 'limit' => null, 'null' => false, - 'signed' => true, ]) ->changeColumn('title', 'text', [ 'default' => null, @@ -53,7 +52,15 @@ public function up(): void 'length' => null, 'limit' => null, 'null' => false, - 'signed' => true, + ]) + ->update(); + + $this->table('tags') + ->changeColumn('id', 'integer', [ + 'default' => null, + 'length' => null, + 'limit' => null, + 'null' => false, ]) ->update(); @@ -63,7 +70,6 @@ public function up(): void 'length' => null, 'limit' => null, 'null' => false, - 'signed' => true, ]) ->update(); $this->table('categories') @@ -76,7 +82,7 @@ public function up(): void 'default' => null, 'limit' => null, 'null' => false, - 'signed' => true, + 'signed' => false, ]) ->addIndex( $this->index('user_id') @@ -113,7 +119,6 @@ public function up(): void 'null' => true, 'precision' => 5, 'scale' => 5, - 'signed' => true, ]) ->addIndex( $this->index('slug') @@ -128,19 +133,6 @@ public function up(): void ->setName('rating_index') ) ->update(); - - $this->table('articles') - ->addForeignKey( - $this->foreignKey('category_id') - ->setReferencedTable('categories') - ->setReferencedColumns('id') - ->setOnDelete('NO_ACTION') - ->setOnUpdate('NO_ACTION') - ->setName('articles_ibfk_1') - ) - ->update(); - - $this->table('tags')->drop()->save(); } /** @@ -158,18 +150,6 @@ public function down(): void 'user_id' )->save(); - $this->table('articles') - ->dropForeignKey( - 'category_id' - )->save(); - $this->table('tags') - ->addColumn('name', 'string', [ - 'default' => null, - 'limit' => 255, - 'null' => false, - ]) - ->create(); - $this->table('articles') ->removeIndexByName('UNIQUE_SLUG') ->removeIndexByName('category_id') @@ -229,6 +209,15 @@ public function down(): void ) ->update(); + $this->table('tags') + ->changeColumn('id', 'integer', [ + 'autoIncrement' => true, + 'default' => null, + 'length' => 11, + 'null' => false, + ]) + ->update(); + $this->table('users') ->changeColumn('id', 'integer', [ 'autoIncrement' => true, diff --git a/tests/comparisons/Diff/simple/the_diff_simple_mysql.php b/tests/comparisons/Diff/simple/the_diff_simple_mysql.php index 9af124d4b..93edeb6d8 100644 --- a/tests/comparisons/Diff/simple/the_diff_simple_mysql.php +++ b/tests/comparisons/Diff/simple/the_diff_simple_mysql.php @@ -22,7 +22,6 @@ public function up(): void 'length' => null, 'limit' => null, 'null' => false, - 'signed' => true, ]) ->changeColumn('rating', 'integer', [ 'default' => null, diff --git a/tests/comparisons/Diff/withAutoIdIncompatibleSignedPrimaryKeys/the_diff_with_auto_id_incompatible_signed_primary_keys_mysql.php b/tests/comparisons/Diff/withAutoIdIncompatibleSignedPrimaryKeys/the_diff_with_auto_id_incompatible_signed_primary_keys_mysql.php index 2a82dde28..1a645545d 100644 --- a/tests/comparisons/Diff/withAutoIdIncompatibleSignedPrimaryKeys/the_diff_with_auto_id_incompatible_signed_primary_keys_mysql.php +++ b/tests/comparisons/Diff/withAutoIdIncompatibleSignedPrimaryKeys/the_diff_with_auto_id_incompatible_signed_primary_keys_mysql.php @@ -23,7 +23,7 @@ public function up(): void 'default' => null, 'limit' => null, 'null' => false, - 'signed' => true, + 'signed' => false, ]) ->addPrimaryKey(['id']) ->create(); @@ -47,7 +47,6 @@ public function down(): void 'default' => null, 'limit' => null, 'null' => false, - 'signed' => true, ]) ->addPrimaryKey(['id']) ->create(); diff --git a/tests/comparisons/Migration/test_snapshot_with_auto_id_compatible_signed_primary_keys.php b/tests/comparisons/Migration/test_snapshot_with_auto_id_compatible_signed_primary_keys.php index fed9f8d73..df2ea8ba0 100644 --- a/tests/comparisons/Migration/test_snapshot_with_auto_id_compatible_signed_primary_keys.php +++ b/tests/comparisons/Migration/test_snapshot_with_auto_id_compatible_signed_primary_keys.php @@ -142,7 +142,6 @@ public function up(): void 'default' => null, 'limit' => null, 'null' => false, - 'signed' => true, ]) ->addPrimaryKey(['id']) ->addColumn('title', 'string', [ diff --git a/tests/comparisons/Migration/test_snapshot_with_auto_id_incompatible_signed_primary_keys.php b/tests/comparisons/Migration/test_snapshot_with_auto_id_incompatible_signed_primary_keys.php index 7973d8735..11fadb44f 100644 --- a/tests/comparisons/Migration/test_snapshot_with_auto_id_incompatible_signed_primary_keys.php +++ b/tests/comparisons/Migration/test_snapshot_with_auto_id_incompatible_signed_primary_keys.php @@ -142,7 +142,6 @@ public function up(): void 'default' => null, 'limit' => null, 'null' => false, - 'signed' => true, ]) ->addPrimaryKey(['id']) ->addColumn('title', 'string', [ diff --git a/tests/comparisons/Migration/test_snapshot_with_non_default_collation.php b/tests/comparisons/Migration/test_snapshot_with_non_default_collation.php index 9c2a79145..45cad82a0 100644 --- a/tests/comparisons/Migration/test_snapshot_with_non_default_collation.php +++ b/tests/comparisons/Migration/test_snapshot_with_non_default_collation.php @@ -119,7 +119,7 @@ public function up(): void $this->table('events') ->addColumn('title', 'string', [ - 'collation' => 'utf8mb3_hungarian_ci', + 'collation' => 'utf8_hungarian_ci', 'default' => null, 'limit' => 255, 'null' => true, diff --git a/tests/test_app/config/DropColumnFkIndexRegression/20190928205056_first_fk_index_migration.php b/tests/test_app/config/DropColumnFkIndexRegression/20190928205056_first_fk_index_migration.php index 5e9ea7768..a24c27de9 100644 --- a/tests/test_app/config/DropColumnFkIndexRegression/20190928205056_first_fk_index_migration.php +++ b/tests/test_app/config/DropColumnFkIndexRegression/20190928205056_first_fk_index_migration.php @@ -19,6 +19,7 @@ public function up() 'null' => false, 'limit' => 20, 'identity' => true, + 'signed' => false, ]) ->create(); @@ -35,6 +36,7 @@ public function up() 'null' => false, 'limit' => 20, 'identity' => true, + 'signed' => false, ]) ->create(); @@ -51,11 +53,13 @@ public function up() 'null' => false, 'limit' => 20, 'identity' => true, + 'signed' => false, ]) ->addColumn('table2_id', 'integer', [ 'null' => true, 'limit' => 20, 'after' => 'id', + 'signed' => false, ]) ->addIndex(['table2_id'], [ 'name' => 'table1_table2_id', @@ -69,6 +73,7 @@ public function up() ->addColumn('table3_id', 'integer', [ 'null' => true, 'limit' => 20, + 'signed' => false, ]) ->addIndex(['table3_id'], [ 'name' => 'table1_table3_id', diff --git a/tests/test_app/config/MigrationsDiffDefault/20151218183450_CreateArticlesDefault.php b/tests/test_app/config/MigrationsDiffDefault/20151218183450_CreateArticlesDefault.php index d561bb834..e05ac0cf0 100644 --- a/tests/test_app/config/MigrationsDiffDefault/20151218183450_CreateArticlesDefault.php +++ b/tests/test_app/config/MigrationsDiffDefault/20151218183450_CreateArticlesDefault.php @@ -6,7 +6,7 @@ class CreateArticlesDefault extends BaseMigration { public function change(): void { - $table = $this->table('articles'); + $table = $this->table('articles', ['signed' => false]); $table ->addColumn('title', 'string', [ 'default' => null, diff --git a/tests/test_app/config/MigrationsDiffDefault/20160128183952_CreateUsersDefault.php b/tests/test_app/config/MigrationsDiffDefault/20160128183952_CreateUsersDefault.php index 6fd767206..f1e3b5685 100644 --- a/tests/test_app/config/MigrationsDiffDefault/20160128183952_CreateUsersDefault.php +++ b/tests/test_app/config/MigrationsDiffDefault/20160128183952_CreateUsersDefault.php @@ -14,7 +14,7 @@ class CreateUsersDefault extends BaseMigration */ public function change(): void { - $table = $this->table('users'); + $table = $this->table('users', ['signed' => false]); $table->addColumn('username', 'string', [ 'default' => null, 'limit' => 255, diff --git a/tests/test_app/config/MigrationsDiffDefault/20160414193900_CreateTagsDefault.php b/tests/test_app/config/MigrationsDiffDefault/20160414193900_CreateTagsDefault.php index e1f87ef2e..e4776347a 100644 --- a/tests/test_app/config/MigrationsDiffDefault/20160414193900_CreateTagsDefault.php +++ b/tests/test_app/config/MigrationsDiffDefault/20160414193900_CreateTagsDefault.php @@ -14,7 +14,7 @@ class CreateTagsDefault extends BaseMigration */ public function change(): void { - $table = $this->table('tags'); + $table = $this->table('tags', ['signed' => false]); $table->addColumn('name', 'string', [ 'default' => null, 'limit' => 255,