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

Integers without signed declarations must be unsigned by default #2267

Open
dereuromark opened this issue Mar 5, 2024 · 0 comments
Open
Labels
Milestone

Comments

@dereuromark
Copy link
Member

dereuromark commented Mar 5, 2024

This is an inconsistency that triggers multiple issues along the road

Right now, not defining table primary key gets it added as "int unsigned".
But any integer added would be "signed", especially problematic for foreign keys, since those together with indexes (unique!) will cause DB errors.

So I propose that signed is false by default when the primary key is generated unsigned by default to match this

Example:

$this->table('comments')
            ->addColumn('user_id', 'integer', [
                'default' => null,
                'null' => true,
                //'signed' => false, Should not be needed anymore unless someone needs a signed field here
            ])

should be

  `id` int UNSIGNED NOT NULL,
  `user_id` int UNSIGNED DEFAULT NULL,

When baking snapshots this also usually causes the

public bool $autoId = false;

and each primary key manually being added extra into the table definitions.
Also quite cumbersome and not DRY

This would probably also be resolved with it.

@dereuromark dereuromark added the bug label Mar 5, 2024
@dereuromark dereuromark added this to the 0.15.x milestone Mar 5, 2024
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

1 participant