ItSolutionStuff.com

How to Run Migration and Seeder on Laravel Vapor?

By Hardik Savani • November 5, 2023
Laravel

This simple article demonstrates of how to run migration on laravel vapor. i explained simply about laravel vapor run migration and seeder. we will help you to give example of how to run migrations automatically in laravel vapor . i would like to show you laravel vapor migration run example. Let's get started with how to run migration and seeder on laravel vapor.

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

i hope it can help you...

Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

Laravel Vapor cli installation error for require league/flysystem-aws-s3-v3

Read Now →

How to Remove index.php from url in Laravel?

Read Now →

How to Setup Database in Laravel Vapor?

Read Now →

How to Deploy Project with Laravel Vapor?

Read Now →

Laravel Http Curl Get Request Example

Read Now →

Laravel Sweet Alert Confirm Delete Example

Read Now →

How to Restore Deleted Records in Laravel?

Read Now →

Laravel 8 Socialite Login with Google Account Example

Read Now →

Laravel 8 Inertia JS CRUD with Jetstream & Tailwind CSS

Read Now →

Laravel 8 Change Date Format Examples

Read Now →