Repository navigation
Fix sp:install skipping migrations on a fresh install - #344
Merged
Merged
Conversation
sp:install creates the .env file while it is running, so the application is still in the production environment when it runs migrations. Laravel's migrate command then asks "Are you sure you want to run this command?" with "No" as the default, after the user has already agreed to run migrations. Accepting that default skipped the migrations, printed "Database migrations successful" anyway, and crashed on the missing users table. Pass --force since the user has already confirmed, and only report success if migrate succeeds. Affects sp:install and sp:upgrade. Amp-Thread-ID: https://ampcode.com/threads/T-01a12ce4-5849-7298-9b52-0f19594ee434
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.
On a fresh install,
sp:installcreates the.envfile while it's running, so the application is still in the production environment when it runs migrations. After the user agrees to "There are pending database migrations. Would you like to run migrations now?", Laravel'smigrateasks a second question, "Are you sure you want to run this command?", with No selected by default. Pressing Enter there:Table 'users' doesn't exist.This has been the behaviour since v3 and affects
sp:installandsp:upgrade.Changes
HasSendportalMigrationHandlers::runMigrations()passes--forcetomigrate, because the user has already confirmed, and only reports success ifmigratesucceeds. If it fails, the existing "Database migrations must be run before setup can be completed." error is shown.MigrationHandlersTest. On the old code it fails withUnexpected question "Are you sure you want to run this command?"; with this change it passes.The full suite passes on MySQL and PostgreSQL. A fresh
sp:installfrom this branch, pressing Enter at the migrations prompt, now completes and the admin can log in.