Laravel specific table Migration
Laravel specific table Migration
In this session, we will try our hand at solving the "Laravel specific table Migration".
-
Migrate a particular table in laravel
--PATH /database/migrations/<your_file_name>.phpphp artisan migrate --path=/database/migrations/2021_04_09_053158_create_projects_table.php
You can run a migration command to create a migration for a specific file under the database/migrations folder. Change the file name as per your file name instead of
2021_04_09_053158_create_projects_table.php
in my case and after that run migrate command. You table structure will be successfully created after the migrate command. -
Create Migrations In Different Folder In Laravel
php artisan migrate:make create_payments_table --path=app/migrations/payments
You can use the same --path option while creating migration and it will easily create the migration in the newly defined path. After running the above command new migration will be created into the app/migrations/payments folder.
-
Run All Migrations In Different Folder In Laravel
php artisan migrate --path=app/migrations/payments
we have created new migrations in a different folder structure (
app/migrations/payments
) thandatabase/migrations
. You can run all that migrations by using same--path
option withphp artisan migrate
command. -
How do I run a specific migration table?
- Migrate
php artisan migrate --path=/database/migrations/fileName.php
. - Roolback
php artisan migrate:rollback --path=/database/migrations/fileName.php
. - Refresh
php artisan migrate:refresh --path=/database/migrations/fileName.php
.
- Migrate
-
How to Migrate Specific File from Migration in Laravel?
To run the specific migration in Laravel, you need to use –path option with the php artisan migrate command. Let's take a simple example, we have '2019_12_04_131405_create_payments_table. php' migration in the database/migrations directory and we would like to run this migration.
-
How to migrate single migration in Laravel?
We just need to migrate only single or specific migration. If we run normal migrate command it will migrate all the migrations written in the application. Here i will let you know to migrate single migration in laravel. Now if we want to run only one migration or a specific migration, we will need to define a path parameter and will need to specify the path of that migration file which we want to run. eg:
php artisan migrate --path=/database/migrations/my_migration.php
.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Laravel
- SQLSTATE[23000]: Integrity constraint violation: 1022 Can't write; duplicate key in table
- Laravel pagination links with query string
- Generate unique username in Laravel
- Extract only time from datetime in laravel
- Get last week data in Laravel
- Redirect to another view from controller in laravel
- How to access the nth object from Laravel collection object ?
- How to display HTML tags In Laravel blade
- Get duplicate records in laravel
- How to validate URL with https using regex in laravel
- Php artisan make model, factory, migration and controller in single command
- How to make Copy or Duplicate table row in laravel
- How to start websocket server in laravel
- How to check column value of a record is null or not in laravel
- Wheredate in laravel not working
- How to add script on specific view file in laravel while extending layout
- How to create project_user pivot table in laravel
- Return view from route Laravel
- Call to undefined function Illuminate\Encryption\openssl_cipher_iv_length()
- FirstOrCreate() Not Inserting Model
- How to add unique records in pivot columns of Laravel pivot table
- How to Get records between two dates in Laravel
- How to display pivot table column value in laravel
- Laravel clone model
- Laravel order by date not working