Open
Conversation
179590b to
415523f
Compare
markstory
reviewed
Mar 14, 2026
Comment on lines
+136
to
+140
| $continue = $io->askChoice( | ||
| 'This will permanently delete all data. Do you want to continue?', | ||
| ['y', 'n'], | ||
| 'n', | ||
| ); |
Member
There was a problem hiding this comment.
👍 Thanks for making this safe by default.
markstory
reviewed
Mar 15, 2026
markstory
reviewed
Mar 17, 2026
Comment on lines
+283
to
+284
| // SQL Server doesn't support disabling FK checks globally. | ||
| // We drop all foreign key constraints instead. |
Member
There was a problem hiding this comment.
Are you sure? We have
return 'EXEC sp_MSforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"';in cakephp/database for sqlserver's disableForeignKey method. Any reason we can't use that here?
Member
Author
There was a problem hiding this comment.
I went with dropping FK constraints instead of using NOCHECK CONSTRAINT all. The reason is that NOCHECK only disables constraint checking but doesn't allow dropping tables that are referenced by foreign keys.
Since we're dropping all tables in a reset, we need to actually remove the constraints first. After the reset, migrations recreate everything fresh anyway.
Implements the "nuclear option" for migrations as discussed in #972: - Drops all application tables (excluding migration tracking tables) - Re-runs all migrations from scratch - Requires interactive Y/N confirmation for safety (default: N) - Supports --dry-run mode to preview changes - Dispatches Migration.beforeReset and Migration.afterReset events This is useful during development when you want a fresh database without manually rolling back or dropping tables. Refs #972
- PostgreSQL: Use CASCADE in DROP TABLE statement - SQL Server: Drop foreign key constraints first before dropping tables - MySQL/SQLite: Continue using session-level FK check toggle
- Remove sessions from protected tables (true nuclear option) - Rename protectedTables to trackingTables for clarity - Clear seed records (cake_seeds) along with migration records - Rename clearMigrationRecords to clearTrackingRecords
Instead of preserving tracking tables and clearing their records, just drop everything and let migrations recreate the tables.
- Replace string operations on class names with instanceof checks - Extract runMigrationsAndDispatch() to reduce code duplication
- Add disableForeignKeyConstraints/enableForeignKeyConstraints to AdapterInterface - Implement FK methods in MysqlAdapter (SET FOREIGN_KEY_CHECKS) - Implement FK methods in SqliteAdapter (PRAGMA foreign_keys) - Implement FK methods in SqlserverAdapter (drop all FK constraints) - PostgresAdapter uses no-op methods with CASCADE in dropTable - Add FK methods to AdapterWrapper for delegation - Refactor ResetCommand to use adapter methods instead of dialect-specific code
e14c73c to
48ddf9e
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Implements the
migrations resetcommand as requested in #972.This is a "nuclear option" that:
cake_migrations,phinxlog)Features
--dry-runflag to preview what would be dropped--no-lockflag to skip lock file generation--plugin,--connection, and--sourceoptionsMigration.beforeResetandMigration.afterReseteventsUsage
Closes #972