-
Notifications
You must be signed in to change notification settings - Fork 120
Default to signed for all int columns, opt-in for unsigned #956
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
Open
dereuromark
wants to merge
13
commits into
5.x
Choose a base branch
from
5.x-unsigned
base: 5.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+491
−66
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8cdb289
Make unsigned the default for int columns.
dereuromark 0503b5c
Opt-in for unsigned column defaults.
dereuromark 3b452cd
Opt-in for unsigned column defaults.
dereuromark b9ad72a
Opt-in for unsigned column defaults.
dereuromark d9e4fbd
Opt-in for unsigned column defaults.
dereuromark 22b5936
Fix tests.
dereuromark c523378
Merge branch '5.x' into 5.x-unsigned
dereuromark f6ad5c5
Merge branch '5.x' into 5.x-unsigned
dereuromark deecb9d
Fix tests.
dereuromark 6c61825
Add migration guide.
dereuromark f26f86c
Remove RunInSeparateProcess from ColumnTest
dereuromark 5c4bb5f
Fix MigrationHelperTest failing when run with adapter tests
dereuromark 3292314
Merge branch '5.x' into 5.x-unsigned
dereuromark File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| Upgrading from 4.x to 5.x | ||
| ######################### | ||
|
|
||
| Migrations 5.x includes significant changes from 4.x. This guide outlines | ||
| the breaking changes and what you need to update when upgrading. | ||
|
|
||
| Requirements | ||
| ============ | ||
|
|
||
| - **PHP 8.2+** is now required (was PHP 8.1+) | ||
| - **CakePHP 5.3+** is now required | ||
| - **Phinx has been removed** - The builtin backend is now the only supported backend | ||
|
|
||
| If you were already using the builtin backend in 4.x (introduced in 4.3, default in 4.4), | ||
| the upgrade should be straightforward. See :doc:`upgrading-to-builtin-backend` for more | ||
| details on API differences between the phinx and builtin backends. | ||
|
|
||
| Command Changes | ||
| =============== | ||
|
|
||
| The phinx wrapper commands have been removed. The new command structure is: | ||
|
|
||
| Migrations | ||
| ---------- | ||
|
|
||
| The migration commands remain unchanged: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| bin/cake migrations migrate | ||
| bin/cake migrations rollback | ||
| bin/cake migrations status | ||
| bin/cake migrations mark_migrated | ||
| bin/cake migrations dump | ||
|
|
||
| Seeds | ||
| ----- | ||
|
|
||
| Seed commands have changed: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| # 4.x # 5.x | ||
| bin/cake migrations seed bin/cake seeds run | ||
| bin/cake migrations seed --seed X bin/cake seeds run X | ||
|
|
||
| The new seed commands are: | ||
|
|
||
| - ``bin/cake seeds run`` - Run seed classes | ||
| - ``bin/cake seeds run SeedName`` - Run a specific seed | ||
| - ``bin/cake seeds status`` - Show seed execution status | ||
| - ``bin/cake seeds reset`` - Reset seed execution tracking | ||
|
|
||
| Maintaining Backward Compatibility | ||
| ---------------------------------- | ||
|
|
||
| If you need to maintain the old ``migrations seed`` command for existing scripts or | ||
| CI/CD pipelines, you can add command aliases in your ``src/Application.php``:: | ||
|
|
||
| public function console(CommandCollection $commands): CommandCollection | ||
| { | ||
| $commands = $this->addConsoleCommands($commands); | ||
|
|
||
| // Add backward compatibility alias | ||
| $commands->add('migrations seed', \Migrations\Command\SeedCommand::class); | ||
|
|
||
| return $commands; | ||
| } | ||
|
|
||
| Removed Classes and Namespaces | ||
| ============================== | ||
|
|
||
| The following have been removed in 5.x: | ||
|
|
||
| - ``Migrations\Command\Phinx\*`` - All phinx wrapper commands | ||
| - ``Migrations\Command\MigrationsCommand`` - Use ``bin/cake migrations`` entry point | ||
| - ``Migrations\Command\MigrationsSeedCommand`` - Use ``bin/cake seeds run`` | ||
| - ``Migrations\Command\MigrationsCacheBuildCommand`` - Schema cache is managed differently | ||
| - ``Migrations\Command\MigrationsCacheClearCommand`` - Schema cache is managed differently | ||
| - ``Migrations\Command\MigrationsCreateCommand`` - Use ``bin/cake bake migration`` | ||
|
|
||
| If you have code that directly references any of these classes, you will need to update it. | ||
|
|
||
| API Changes | ||
| =========== | ||
|
|
||
| Adapter Query Results | ||
| --------------------- | ||
|
|
||
| If your migrations use ``AdapterInterface::query()`` to fetch rows, the return type has | ||
| changed from a phinx result to ``Cake\Database\StatementInterface``:: | ||
|
|
||
| // 4.x (phinx) | ||
| $stmt = $this->getAdapter()->query('SELECT * FROM articles'); | ||
| $rows = $stmt->fetchAll(); | ||
| $row = $stmt->fetch(); | ||
|
|
||
| // 5.x (builtin) | ||
| $stmt = $this->getAdapter()->query('SELECT * FROM articles'); | ||
| $rows = $stmt->fetchAll('assoc'); | ||
| $row = $stmt->fetch('assoc'); | ||
|
|
||
| New Features in 5.x | ||
| =================== | ||
|
|
||
| 5.x includes several new features: | ||
|
|
||
| Seed Tracking | ||
| ------------- | ||
|
|
||
| Seeds are now tracked in a ``cake_seeds`` table by default, preventing accidental re-runs. | ||
| Use ``--force`` to run a seed again, or ``bin/cake seeds reset`` to clear tracking. | ||
| See :doc:`seeding` for more details. | ||
|
|
||
| Check Constraints | ||
| ----------------- | ||
|
|
||
| Support for database check constraints via ``addCheckConstraint()``. | ||
| See :doc:`writing-migrations` for usage details. | ||
|
|
||
| MySQL ALTER Options | ||
| ------------------- | ||
|
|
||
| Support for ``ALGORITHM`` and ``LOCK`` options on MySQL ALTER TABLE operations, | ||
| allowing control over how MySQL performs schema changes. | ||
|
|
||
| insertOrSkip() for Seeds | ||
| ------------------------ | ||
|
|
||
| New ``insertOrSkip()`` method for seeds to insert records only if they don't already exist, | ||
| making seeds more idempotent. | ||
|
|
||
| Migration File Compatibility | ||
| ============================ | ||
|
|
||
| Your existing migration files should work without changes in most cases. The builtin backend | ||
| provides the same API as phinx for common operations. | ||
|
|
||
| If you encounter issues with existing migrations, please report them at | ||
| https://github.com/cakephp/migrations/issues |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should deprecate this on the Cake ORM maybe?
We dont need isUnsigned() and isSigned() at the same time, do we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ORM API is part of the additions in 5.3. If we deprecate that it requires changes to cakephp/database and the orm. I thought we could align on what we already have in the core.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you propose we do?
Since it we shouldnt have both positive and negative form at the same time here in the new major.
Or in other words: Wouldn't it be cleaner to only have one side, and not the other on top?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes of course, one way would be preferable. However migrations and cake started in opposite directions, and in order for us to provide backwards compatibility we have to support both for a while.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thus my proposal to deprecate but keep around.
otherwise feel free to modify as needed so we can merge and move forward