3

sorry for silly question but I'm really facing problem. After migrating all the migration files. When I need another features for my project I have to make another table but When I'm going to migrate the new table using "php artisan migrate:rollback" or "php artisan migrate:rollback step=17" .... all the migration files are migrating this time too and I am losing all previous data. Then How can I migrate only the new one?

3 Answers3

5

To migrate only new migrations is simple: php artisan migrate. The way the process works is that Laravel creates a table in your database called migrations. In that table are the names of the migrations that have been run already. If there are new migrations the above command will work.

You can read more about running migrations in the documentation.

Alex Harris
  • 6,172
  • 2
  • 32
  • 57
1

To migrate any new migration created php artisan migrate is the artisan command.
To get the details of all commands php artisan is the artisan command.
To get the details of any specific command php artisan help command-name-here.

Khushal
  • 249
  • 4
  • 19
0

In the case of creating a new file, you only need to run php artisan migrate again.

If you want modify original migration file and migrate it again, you can use this package to migrate.

First, install package in your Laravel project:

composer require caloskao/migrate-specific

Register command at app/Console/Kernel.php :

protected $commands = [
    \CalosKao\MigrateSpecific::class
];

Now, run this command to migrate your file

php artisan migrate:specific database/migrations/table.php
Calos
  • 1,783
  • 19
  • 28