-
Notifications
You must be signed in to change notification settings - Fork 121
Description
Note: my app uses several plugins with their own migrations. I'm sure everything is currently migrated correctly.
I also get feedback with bin/cake migrations status (and with -p option).
Now I'm trying to do a migration_diff on the app, but I get:
$ bin/cake bake migration_diff AddedShowWeatherForecastOnDashboardFieldToUsersSettingsTable
Your migrations history is not in sync with your migrations files. Make sure all your migrations have been migrated before baking a diff.
So I took a look at the BakeMigrationDiffCommand::checkSync() method, in particular here:
$lastVersion = $this->migratedItems[0]['version'];
$lastFile = end($this->migrationsFiles);I noticed that $lastVersion does report the last migration, but in my specific case the last migration belongs to a plugin.
While $lastFile reports the last file, but from the app.
As a counter-proof, if I try to do migration_diff using the plugin to which the last migration belongs, then it works:
$ bin/cake bake migration_diff AddedShowWeatherForecastOnDashboardFieldToUsersSettingsTable -p Schedules
Creating file /home/mirko/PhpstormProjects/climat/plugins/Schedules/config/Migrations/20260328102052_AddedShowWeatherForecastOnDashboardFieldToUsersSettingsTable.php
Wrote `/home/mirko/PhpstormProjects/climat/plugins/Schedules/config/Migrations/20260328102052_AddedShowWeatherForecastOnDashboardFieldToUsersSettingsTable.php`
Marking the migration 20260328102052_AddedShowWeatherForecastOnDashboardFieldToUsersSettingsTable as migrated...
Migration `20260328102052` successfully marked migrated !
Creating a dump of the new database state...
I'm not entirely sure I didn't mess something up myself (I recently implemented some migrations manually), but I wouldn't want BakeMigrationDiffCommand to not distinguish between apps and plugins when checking for proper migration synchronization.
EDIT for completeness of information
$ bin/cake migrations status
using migration table cake_migrations
+--------+-----------------+--------------------------------------------------------------+
| Status | Migration ID | Migration Name |
+--------+-----------------+--------------------------------------------------------------+
| up | 20250905070135 | AppInitial |
| up | 20251021223749 | RenamedUsersLoginsTableAsUsersLogs |
| up | 20251021224645 | RenamedCreatedFieldAsDatetimeForUsersLogsTable |
| up | 20251028000000 | AddSystolicDiastolicColumnsAndTriggers |
| up | 20260128195248 | AddedRoleFieldToUsersGroupsTable |
| up | 20260129145200 | RoleFieldFromUsersGroupsTableIsNotNullable |
| up | 20260129145721 | RemovedLabelAndActiveFieldsFromUsersGroupsTable |
| up | 20260129153139 | RemovedActiveFieldsFromAllCategoriesTable |
| up | 20260217201139 | RemovedNotificationsAndNotificationsTables |
| up | 20260227163918 | AddedUsersSettingsTable |
| up | 20260312104636 | AddedIndexToPrescriptionTypeFieldForDrugsPrescriptionsTable |
| up | 20260312104838 | RenamedDayRangeFieldAsIntervalDaysForDrugsPrescriptionsTable |
| up | 20260320091053 | RemovedExpirationsAndExpirationsCategoriesTables |
| up | 20260320091232 | RemovedPatientsExpirationsTable |
| up | 20260320091311 | RemovedPatientsPermissionsTable |
+--------+-----------------+--------------------------------------------------------------+
$ bin/cake migrations status -p Schedules
using migration table cake_migrations
+--------+-----------------+-------------------------------------------------------+
| Status | Migration ID | Migration Name |
+--------+-----------------+-------------------------------------------------------+
| up | 20260119090146 | SchedulesInitial |
| up | 20260326143200 | AddedAllowsInDashboardFieldToSchedulesCategoriesTable |
+--------+-----------------+-------------------------------------------------------+
In fact, the checkSync() recognizes 20260326143200 as the latest.
