You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enhance Laravel automation scripts with new migration options and improved error handling. Added support for multiple databases, migration modes, and seeding. Updated documentation to reflect these changes and added a new script for testing database connections.
|`AUTORUN_LARAVEL_MIGRATION_ISOLATION`|`false`| Run your migrations with the [`--isolated`](https://laravel.com/docs/12.x/migrations#running-migrations) flag. <br> **ℹ️ Note:** Requires Laravel v9.38.0+ |
23
+
|`AUTORUN_LARAVEL_MIGRATION_DATABASE`|`null`| Run migrations on a specific database. In the rare case you need to use multiple databases, you can provide a comma-delimited list of connection names (e.g., "mysql,pgsql"). If `null`, it will use the default database connection. |
24
+
|`AUTORUN_LARAVEL_MIGRATION_FORCE`|`true`| Force migrations to run in production without confirmation. Set to `false` to disable the `--force` flag. |
25
+
|`AUTORUN_LARAVEL_MIGRATION_ISOLATION`|`false`| Run your migrations with the [`--isolated`](https://laravel.com/docs/12.x/migrations#running-migrations) flag. <br> **ℹ️ Note:** Requires Laravel v9.38.0+. Only works with `default` migration mode. |
26
+
|`AUTORUN_LARAVEL_MIGRATION_MODE`|`default`| Migration mode: `default`, `fresh`, or `refresh`. <br> **⚠️ Warning:**`fresh` and `refresh` drop all tables. |
27
+
|`AUTORUN_LARAVEL_MIGRATION_SEED`|`false`| Automatically seed the database after migrations using the `--seed` flag. |
28
+
|`AUTORUN_LARAVEL_MIGRATION_SKIP_DB_CHECK`|`false`| Skip the database connection check before running migrations. |
24
29
|`AUTORUN_LARAVEL_MIGRATION_TIMEOUT`|`30`| Number of seconds to wait for database connection before timing out during migrations. |
25
30
|`AUTORUN_LARAVEL_OPTIMIZE`|`true`|`php artisan optimize`: Optimizes the application. |
26
-
|`AUTORUN_LARAVEL_SEED`|`false`|`php artisan db:seed`: Runs the default seeder. <br> **ℹ️ Note:** Set to `true` to run the default seeder. If you want to run a custom seeder, set this to the name of the seeder class. |
27
31
|`AUTORUN_LARAVEL_ROUTE_CACHE`|`true`|`php artisan route:cache`: Caches the routes. |
28
32
|`AUTORUN_LARAVEL_STORAGE_LINK`|`true`|`php artisan storage:link`: Creates a symbolic link from `public/storage` to `storage/app/public`. |
29
33
|`AUTORUN_LARAVEL_VIEW_CACHE`|`true`|`php artisan view:cache`: Caches the views. |
@@ -42,10 +46,41 @@ Creates a symbolic link from `public/storage` to `storage/app/public`.
42
46
## php artisan migrate
43
47
Before running migrations, we ensure the database is online and ready to accept connections. By default, we will wait 30 seconds before timing out.
44
48
49
+
### Migration Modes
50
+
You can control how migrations run using `AUTORUN_LARAVEL_MIGRATION_MODE`:
51
+
-`default` (default): Runs `php artisan migrate` - standard forward migrations
52
+
-`fresh`: Runs `php artisan migrate:fresh` - drops all tables and re-runs migrations
53
+
-`refresh`: Runs `php artisan migrate:refresh` - rolls back and re-runs migrations
54
+
55
+
::note
56
+
**⚠️ Warning:** Using `fresh` or `refresh` modes will **drop all tables** in your database. Only use these in development or testing environments.
57
+
::
58
+
59
+
### Force Flag
60
+
By default, migrations run with the `--force` flag to bypass production warnings. You can disable this by setting `AUTORUN_LARAVEL_MIGRATION_FORCE` to `false`.
61
+
62
+
### Seeding
63
+
You can automatically seed your database after migrations by setting `AUTORUN_LARAVEL_MIGRATION_SEED` to `true`. This adds the `--seed` flag to your migration command.
64
+
65
+
### Specific Database Migrations
66
+
If you need to specify the exact database connection to use for migrations, you can set `AUTORUN_LARAVEL_MIGRATION_DATABASE` to the name of the database connection you want to use.
67
+
68
+
```bash
69
+
AUTORUN_LARAVEL_MIGRATION_DATABASE=mysql
70
+
```
71
+
72
+
In the rare case you need to use multiple databases, you can provide a comma-delimited list of connection names (e.g., "mysql,pgsql").
73
+
74
+
```bash
75
+
AUTORUN_LARAVEL_MIGRATION_DATABASE=mysql,pgsql
76
+
```
77
+
78
+
### Isolated Migrations
45
79
You can enable the [`--isolated`](https://laravel.com/docs/12.x/migrations#running-migrations) flag by setting `AUTORUN_LARAVEL_MIGRATION_ISOLATION` to `true`, which will ensure no other containers are running a migration.
46
80
47
81
**Special Notes for Isolated Migrations:**
48
82
- Requires Laravel v9.38.0+
83
+
- Only works with `default` migration mode (not compatible with `fresh` or `refresh`)
49
84
- Your application must be using the memcached, redis, dynamodb, database, file, or array cache driver as your application's default cache driver. In addition, all servers must be communicating with the same central cache server.
50
85
51
86
[Read more about migrations →](https://laravel.com/docs/12.x/migrations#running-migrations)
@@ -66,11 +101,6 @@ This command caches all configuration files into a single file, which can then b
66
101
67
102
[Read more about configuration caching →](https://laravel.com/docs/12.x/configuration#configuration-caching)
68
103
69
-
## php artisan db:seed
70
-
This command runs the default seeder. If you want to run a custom seeder, set `AUTORUN_LARAVEL_SEED` to the name of the seeder class.
71
-
72
-
[Read more about seeding →](https://laravel.com/docs/12.x/seeding)
73
-
74
104
## php artisan route:cache
75
105
This command caches the routes, dramatically decrease the time it takes to register all of your application's routes. After running this command, your cached routes file will be loaded on every request.
Copy file name to clipboardExpand all lines: docs/content/docs/7.reference/1.environment-variable-specification.md
+5-2Lines changed: 5 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,11 +26,14 @@ We like to customize our images on a per app basis using environment variables.
26
26
`AUTORUN_LARAVEL_CONFIG_CACHE`<br />*Default: "true"*|Automatically run "php artisan config:cache" on container start. <br />ℹ️ Requires `AUTORUN_ENABLED = true` to run.| all
27
27
`AUTORUN_LARAVEL_EVENT_CACHE`<br />*Default: "true"*|Automatically run "php artisan event:cache" on container start. <br />ℹ️ Requires `AUTORUN_ENABLED = true` to run.| all
28
28
`AUTORUN_LARAVEL_MIGRATION`<br />*Default: "true"*|Automatically run `php artisan migrate --force` on container start. <br />ℹ️ Requires `AUTORUN_ENABLED = true` to run.| all
29
-
`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
29
+
`AUTORUN_LARAVEL_MIGRATION_DATABASE`<br />*Default: null*| Run migrations on a specific database. In the rare case you need to use multiple databases, you can provide a comma-delimited list of connection names (e.g., "mysql,pgsql"). If `null`, it will use the default database connection. <br />ℹ️ Requires `AUTORUN_ENABLED = true` to run.| all
30
+
`AUTORUN_LARAVEL_MIGRATION_FORCE`<br />*Default: "true"*|Force migrations to run in production without confirmation. Set to `false` to disable the `--force` flag. <br />ℹ️ Requires `AUTORUN_ENABLED = true` to run.| all
31
+
`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.<br />ℹ️ Only works with `AUTORUN_LARAVEL_MIGRATION_MODE = default`.| all
32
+
`AUTORUN_LARAVEL_MIGRATION_MODE`<br />*Default: "default"*|Set the migration mode. Valid options: `default` (runs `php artisan migrate`), `fresh` (runs `php artisan migrate:fresh`), or `refresh` (runs `php artisan migrate:refresh`). <br />ℹ️ Requires `AUTORUN_ENABLED = true` to run.<br />⚠️ WARNING:`fresh` and `refresh` are destructive and will drop all tables. Only use these in development or testing environments.| all
33
+
`AUTORUN_LARAVEL_MIGRATION_SEED`<br />*Default: "false"*|Automatically seed the database after migrations by adding the `--seed` flag. <br />ℹ️ Requires `AUTORUN_ENABLED = true` to run.| all
30
34
`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
31
35
`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
32
36
`AUTORUN_LARAVEL_ROUTE_CACHE`<br />*Default: "true"*|Automatically run "php artisan route:cache" on container start. <br />ℹ️ Requires `AUTORUN_ENABLED = true` to run.| all
33
-
`AUTORUN_LARAVEL_SEED`<br />*Default: "false"*|Automatically run database seeder on container start. Set to `true` to run the default seeder (`php artisan db:seed --force`), or provide a custom seeder class name (e.g., `DatabaseSeeder`) to run a specific seeder (`php artisan db:seed --seeder=DatabaseSeeder`). <br />ℹ️ Requires `AUTORUN_ENABLED = true` to run.| all
34
37
`AUTORUN_LARAVEL_STORAGE_LINK`<br />*Default: "true"*|Automatically run "php artisan storage:link" on container start. <br />ℹ️ Requires `AUTORUN_ENABLED = true` to run.| all
35
38
`AUTORUN_LARAVEL_VIEW_CACHE`<br />*Default: "true"*|Automatically run "php artisan view:cache" on container start. <br />ℹ️ Requires `AUTORUN_ENABLED = true` to run.| all
0 commit comments