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

Problem with BLOB type when baking a migration #484

Open
2 of 3 tasks
hacheraw opened this issue Jan 10, 2021 · 0 comments
Open
2 of 3 tasks

Problem with BLOB type when baking a migration #484

hacheraw opened this issue Jan 10, 2021 · 0 comments
Labels

Comments

@hacheraw
Copy link

hacheraw commented Jan 10, 2021

This is a (multiple allowed):

  • bug

  • enhancement

  • feature-discussion (RFC)

  • CakePHP Version: 4.2.2

  • Platform and Target: Windows 10 (XAMPP) PHP 7.2, 10.1.35-MariaDB

What you did

I have some BLOB and MEDIUMBLOB columns on Database:

-- EXAMPLE
CREATE TABLE `measures` (
  `id` int(11) NOT NULL,
  `title` blob NOT NULL,
  `text` mediumblob NOT NULL,
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL,
  `deleted` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

What happened

This is the resulting code after running bin/cake bake migration_diff measures:

$this->table('measures')
    ->addColumn('title', 'binary', [
        'default' => null,
        'limit' => null, // <----- PROBLEM HERE
        'null' => false,
    ])
    ->addColumn('text', 'binary', [
        'default' => null,
        'limit' => 16777215,
        'null' => false,
    ])

The problem is that when you run that migration in another machine using bin/cake migrations migrate

the resulting column type for title is not BLOB but BINARY(255)
image

What you expected to happen

If ColumnType is BLOB, the limit should be 65535. (Stack Overflow)

What you have tried

I edited the migration, replaced the 'limit' => null with 'limit' => 65535 and ran the migration in a blank database. It worked as espected.
image

@othercorey othercorey transferred this issue from cakephp/cakephp Jan 11, 2021
@markstory markstory added the bug label Jan 11, 2021
@saeideng saeideng added this to the 3.x (CakePHP 4) milestone Jan 11, 2021
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

3 participants