migrations icon indicating copy to clipboard operation
migrations copied to clipboard

Add force-autoid config.

Open dereuromark opened this issue 2 years ago • 4 comments

With the

'Migrations.unsigned_primary_keys'

we introduced some issues around baking a fresh snapshot. The autoid gets cancelled with the slightest issue for ALL tables, making it super hard to clean that up.

I would like to propose a force-autoid config that allows to overwrite the "detected" one for those that want/need it.

I didnt quite figure out the proper twig syntax Apprently this doesnt do it:

set autoId = forceAutoId OR not Migration.hasAutoIdIncompatiblePrimaryKey(tables['add'] + tables['remove'])

Any ideas?

Even setting it to

{% set autoId = true %}

doesnt work, is there some weird extra cache involved?


Alternatively, we could see if hasAutoIdIncompatiblePrimaryKey() could be applied per table, instead of per file.

Refs https://github.com/cakephp/bake/issues/962

dereuromark avatar Dec 12 '23 15:12 dereuromark

Something is really wrong here Even if I set 'Migrations.unsigned_primary_keys' tofalse it still prints the same thing. As if that config doesnt have any effect anymore.

dereuromark avatar Dec 12 '23 15:12 dereuromark

I don't have time currently to get into the migrations stuff again, but you're talking about snapshots, and there is no change in the snapshot template, only in the diff template, which doesn't even receive the option, as it's only been added to the snapshot command.

ndm2 avatar Dec 12 '23 15:12 ndm2

Thx, that explains it, I will recheck tomorrow

dereuromark avatar Dec 20 '23 01:12 dereuromark

Alternatively, we could see if hasAutoIdIncompatiblePrimaryKey() could be applied per table, instead of per file.

Isn't this the better option for end users? Instead of having to learn more flags to get the correct results, they can just use the default behavior which doesn't retain state between tables. That seems like a good improvement with less complexity exposed.

markstory avatar Dec 25 '23 06:12 markstory