cakephp / bake

The Bake Command Plugin
Other
110 stars 100 forks source link

Bake snapshot losing structure data #963

Closed dereuromark closed 6 months ago

dereuromark commented 10 months ago

Description

While trying to squash all migrations files into one by rebaking a initial snapshot the diff seems to outline quite a bit of data loss on the structure of the sql schema

I wonder which ones of those could and should be fixed: https://github.com/dereuromark/cakephp-sandbox/pull/66/commits/8138028970814b4853029ca28229e6096e4d4ee4 All of those are on MySQL

So to outline the important ones:

binary

- `image` blob DEFAULT NULL,
+ `image` binary(255) DEFAULT NULL,

For fixture data

'image' => ['type' => 'binary', 'length' => null, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null],

and generated migrations schema

    ->addColumn('image', 'binary', [
        'default' => null,
        'limit' => null,
        'null' => true,
    ])

tinyint for enum

-  `status` tinyint(2) UNSIGNED NOT NULL DEFAULT 0,             
+  `status` tinyint(4) UNSIGNED NOT NULL DEFAULT 0,

For

'status' => ['type' => 'integer', 'null' => false, 'default' => '0', 'length' => 2],

and generated

->addColumn('status', 'tinyinteger', [
    'default' => '0',
    'limit' => null,
    'null' => false,
    'signed' => false,
])

This refs https://github.com/cakephp/migrations/issues/502

Bake Version

3.x

PHP Version

8.2