Publishing a database migration file of a module in Laravel 6
1. In the startup script of the docker container, if you want to force the migration command to run without prompt, use the –force parameter
php artisan migrate --force
2. At this stage, there is a module developed based on Laravel Modules, and there are migration files, such as: /modules/themestoredb/database/migrations . as shown in Figure 1
3. In the local development environment, execute the migration file under the module, generally running the command: php artisan module:migrate themestoredb . as shown in Figure 2
PS E:\wwwroot\object> php artisan module:migrate ThemeStoreDB
Migrating: 2021_12_06_133918_create_theme_asset_table
Migrated: 2021_12_06_133918_create_theme_asset_table (0.11 seconds)
Migrating: 2021_12_13_145303_create_theme_asset_version_table
Migrated: 2021_12_13_145303_create_theme_asset_version_table (0.1 seconds)
Migrating: 2022_05_16_105847_create_theme_installation_table
Migrated: 2022_05_16_105847_create_theme_installation_table (0.07 seconds)
Migrating: 2022_05_16_134353_create_theme_installation_version_preset_table
Migrated: 2022_05_16_134353_create_theme_installation_version_preset_table (0.21 seconds)
Migrating: 2022_05_16_172815_create_theme_installation_task_table
Migrated: 2022_05_16_172815_create_theme_installation_task_table (0.12 seconds)
4. However, the number of modules is too large, and it is impossible to frequently add the migration command of the corresponding module to the startup script. Reference: module:publish-migration, the database migration file of the publishing module. as shown in Figure 3
PS E:\wwwroot\object> php artisan module:publish-migration ThemeStoreDB
5. Directory: The file under /modules/themestoreDB/database/migrations has been copied to the directory: /database/migrations. as shown in Figure 4
6. In this case, the command to execute the migration in the startup script only needs: php artisan migrate –force, without any changes. Executed in the local environment, no migration executable, in line with expectations.
PS E:\wwwroot\object> php artisan migrate
Nothing to migrate.
PS E:\wwwroot\object>



