Skip to content

Commit 3a03547

Browse files
committed
Add support for skipping database connection checks during Laravel migrations
- Introduced the `AUTORUN_LARAVEL_MIGRATION_SKIP_DB_CHECK` environment variable to allow users to bypass database connection checks before running migrations. - Updated the documentation to reflect this new environment variable and its default behavior.
1 parent 80c794f commit 3a03547

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

docs/content/docs/7.reference/1.environment-variable-specification.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ We like to customize our images on a per app basis using environment variables.
2727
`AUTORUN_LARAVEL_EVENT_CACHE`<br />*Default: "true"*|Automatically run "php artisan event:cache" on container start. <br />ℹ️ Requires `AUTORUN_ENABLED = true` to run.| all
2828
`AUTORUN_LARAVEL_MIGRATION`<br />*Default: "true"*|Automatically run `php artisan migrate --force` on container start. <br />ℹ️ Requires `AUTORUN_ENABLED = true` to run.| all
2929
`AUTORUN_LARAVEL_MIGRATION_ISOLATION`<br />*Default: "false"*|Requires Laravel v9.38.0 or higher and a database that supports table locks. Automatically run `php artisan migrate --force --isolated` on container start. <br /><br />ℹ️ Requires `AUTORUN_ENABLED = true` to run.<br />ℹ️ Does not work with SQLite.| all
30+
`AUTORUN_LARAVEL_MIGRATION_SKIP_DB_CHECK`<br />*Default: "false"*|Skip the database connection check before running migrations. <br />ℹ️ Requires `AUTORUN_ENABLED = true` to run.| all
3031
`AUTORUN_LARAVEL_MIGRATION_TIMEOUT`<br />*Default: "30"*|The number of seconds to wait for the database to come online before attempting `php artisan migrate`.. <br />ℹ️ Requires `AUTORUN_ENABLED = true` to run.| all
3132
`AUTORUN_LARAVEL_ROUTE_CACHE`<br />*Default: "true"*|Automatically run "php artisan route:cache" on container start. <br />ℹ️ Requires `AUTORUN_ENABLED = true` to run.| all
3233
`AUTORUN_LARAVEL_STORAGE_LINK`<br />*Default: "true"*|Automatically run "php artisan storage:link" on container start. <br />ℹ️ Requires `AUTORUN_ENABLED = true` to run.| all

src/common/etc/entrypoint.d/50-laravel-automations.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ script_name="laravel-automations"
2323
: "${AUTORUN_LARAVEL_MIGRATION:=true}"
2424
: "${AUTORUN_LARAVEL_MIGRATION_ISOLATION:=false}"
2525
: "${AUTORUN_LARAVEL_MIGRATION_TIMEOUT:=30}"
26+
: "${AUTORUN_LARAVEL_MIGRATION_SKIP_DB_CHECK:=false}"
2627

2728
# Set default values for seeders
2829
: "${AUTORUN_LARAVEL_SEED:=false}"
@@ -274,6 +275,10 @@ laravel_version_is_at_least() {
274275
}
275276

276277
test_db_connection() {
278+
if [ "$AUTORUN_LARAVEL_MIGRATION_SKIP_DB_CHECK" = "true" ]; then
279+
return 0
280+
fi
281+
277282
php -r "
278283
require '$APP_BASE_DIR/vendor/autoload.php';
279284
use Illuminate\Support\Facades\DB;

0 commit comments

Comments
 (0)