Skip to content

Fix sp:install skipping migrations on a fresh install - #344

Merged
JonoB merged 2 commits into
masterfrom
fix-install-migrations
Oct 12, 2026
Merged

JonoB merged 2 commits into
masterfrom
fix-install-migrations

Conversation

@JonoB

@JonoB JonoB commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

On a fresh install, sp:install creates the .env file 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's migrate asks a second question, "Are you sure you want to run this command?", with No selected by default. Pressing Enter there:

  • skipped the migrations,
  • still printed "✓ Database migrations successful",
  • then crashed with Table 'users' doesn't exist.

This has been the behaviour since v3 and affects sp:install and sp:upgrade.

Changes

  • HasSendportalMigrationHandlers::runMigrations() passes --force to migrate, because the user has already confirmed, and only reports success if migrate succeeds. If it fails, the existing "Database migrations must be run before setup can be completed." error is shown.
  • New MigrationHandlersTest. On the old code it fails with Unexpected 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:install from this branch, pressing Enter at the migrations prompt, now completes and the admin can log in.

JonoB added 2 commits October 12, 2026 10:12
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
@JonoB
JonoB merged commit c76a9cf into master Oct 12, 2026
1 check passed
@JonoB
JonoB deleted the fix-install-migrations branch October 12, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant