How to deploy Laravel Vapor with migration and seeder?
Hi dev,
This short post gives a step-by-step explanation of how to conduct migration on Laravel Vapor. I described clearly about laravel vapour run migration and seeder. We will assist you by providing an example of how to have Laravel Vapor conduct migrations automatically. I'd want to demonstrate a Laravel Vapor Migration Run. Let's begin by discussing how to use Laravel Vapor to execute migration and seeder.
If your app in production then you can not run migration command from vapor website. you must have to run migration from deploy time. laravel vapor provide deploy hook, where you can run migration and seeder command with force.
so let's see both example Run Migration on Vapor:
with deploy hooks:
deploy:
- 'php artisan migrate --force'
vapor.yml
id: 22442
name: itsolutionstuff-vapor
environments:
production:
memory: 1024
cli-memory: 512
runtime: 'php-8.0:al2'
build:
- 'COMPOSER_MIRROR_PATH_REPOS=1 composer install --no-dev'
staging:
memory: 1024
cli-memory: 512
runtime: 'php-8.0:al2'
database: itsolutionstuff-vapor-staging
deploy:
- 'php artisan migrate --force'
build:
- 'COMPOSER_MIRROR_PATH_REPOS=1 composer install'
now just deploy it.
php vendor/bin/vapor deploy
Run Seeder on Vapor: with deploy hooks:
deploy:
- 'php artisan db:seed --class=UserSeeder --force'
vapor.yml
id: 22442
name: itsolutionstuff-vapor
environments:
production:
memory: 1024
cli-memory: 512
runtime: 'php-8.0:al2'
build:
- 'COMPOSER_MIRROR_PATH_REPOS=1 composer install --no-dev'
staging:
memory: 1024
cli-memory: 512
runtime: 'php-8.0:al2'
database: itsolutionstuff-vapor-staging
deploy:
- 'php artisan db:seed --class=UserSeeder --force'
build:
- 'COMPOSER_MIRROR_PATH_REPOS=1 composer install'
now just deploy it.
php vendor/bin/vapor deploy
- How to Notifications With database Driver in Laravel 11?
- How to Send Email Via Notification in Laravel 11?
- How to Install and Configure Laravel 11 Debugbar?
- How to Like Dislike System in Laravel 11?
- How to Paginate a Model with Relationship in Laravel 11?
- Laravel 11 Upload Files to Amazon S3 Example
- Laravel 11 Send WhatsApp Messages Example
- Laravel 11 Rest API Authentication Using JWT Tutorial