Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lost column length with migration_snapshot #361

Closed
1 of 3 tasks
dmromanov opened this issue May 13, 2018 · 1 comment
Closed
1 of 3 tasks

Lost column length with migration_snapshot #361

dmromanov opened this issue May 13, 2018 · 1 comment
Labels

Comments

@dmromanov
Copy link

This is a (multiple allowed):

  • bug

  • enhancement

  • feature-discussion (RFC)

  • CakePHP Version: 3.6.2

  • Migrations plugin version: 1.8.1

  • Bake plugin version (if relevant): 1.7.3

  • Database server (MySQL, SQLite, Postgres): MySQL 5.7, 8.0

  • PHP Version: PHP 7.2.3

  • Platform / OS: Ubuntu 18.04

What you did

We have the following DB.

CREATE TABLE `tests` (
  `id` int(2) NOT NULL AUTO_INCREMENT,
  `ok_int` int(2) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

After running bin/cake bake migration_snapshot TestLength Init I get:

<?php
use Migrations\AbstractMigration;

class TestLength extends AbstractMigration
{
    public function up()
    {

        $this->table('tests')
            ->addColumn('ok_int', 'integer', [
                'default' => null,
                'limit' => 2,
                'null' => false,
            ])
            ->create();
    }

    public function down()
    {
        $this->dropTable('tests');
    }
}

Length of the primary key was dropped. Which resulted in an incorrect DB.
This is critical when using foreign keys in database: a mismatch of column lengths might cause a later created migrations to fail.

bake migraion_diff works and successfulu detects changes in primary column lengths. So it's just for migration_snapshot

Might be related to #331

@dereuromark
Copy link
Member

Int lengths in newer (My)SQL versions are deprecated/removed
See #502

As such there is not much that can be done here apart from what is mentioned in the follow up ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants