Laravel's Artisan says nothing to migrate

╄→尐↘猪︶ㄣ 提交于 2019-12-03 09:29:56

That foo thing is just an example. Laravel will look for migrations to run in app/database/migrations on default. Try removing that --path parameter and see if it works.

user3474053

Try this:

First:

C:\xampp\htdocs\laravel-master>php artisan migrate:reset

Rolled back: 2014_03_28_142140_user_table

Nothing to rollback.

second:

C:\xampp\htdocs\laravel-master>php artisan migrate

Migrated: 2014_03_28_142140_user_table

check the database.

The path argument is for creating a migration for example:

 php artisan migrate:make create_user_table --path=app/database/migrations/user_migrations/

But it is not documented to use while running the migrations, as it was in prior versions of laravel.

Dropping the --path argument should work in your case

What helped me:

php artisan config:cache
php artisan migrate

You don't need to move the migration file anywhere, just change its filename; for example, increase time integer and then run the migrate command with path pointing the migration. e.g: php artisan migrate --path="database/migrations/2019_07_06_145857_create_products_table.php"

Ras

For anyone who still cannot migrate their database:

Assume you have a file to migrate abc_migrate.php.

Firstly put your file inside the new folder named abc_folder. Then, enter this command php artisan migrate --path=database/migrations/abc_folder/.

You don't have to add file name at last of the directory path.

Done. Hope it helps.

The problem arises if the migrations table in the database is empty. So the solution is open up the tinker from the composer

$ php artisan tinker
>>> Schema::drop('users')
>>> Schema::drop('password_resets')
>>> Schema::drop('orders')
>>> exit
php artisan migrate

Here is the result of the above commands executed

nishanth@localhost:~/Desktop/html/hutch$ php artisan migrate

In Connection.php line 647: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' alre ady exists (SQL: create table users (id int unsigned not null auto_incr ement primary key, name varchar(255) not null, email varchar(255) not n ull, password varchar(255) not null, remember_token varchar(100) null, created_at timestamp null, updated_at timestamp null) default character set utf8mb4 collate utf8mb4_unicode_ci)

In Connection.php line 449: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' alre ady exists

nishanth@localhost:~/Desktop/html/hutch$ php artisan migrate:rollback
Nothing to rollback.
nishanth@localhost:~/Desktop/html/hutch$ php artisan tinker
Psy Shell v0.8.17 (PHP 7.1.20-1+ubuntu16.04.1+deb.sury.org+1 — cli) by Justin Hileman
>>> Schema::drop('users')
=> null
>>> Schema::drop('password_resets')
=> null
>>> Schema::drop('orders')
=> null
>>> exit
Exit:  Goodbye.
nishanth@localhost:~/Desktop/html/hutch$ php artisan migrate
Migrating: 2014_10_12_000000_create_users_table
Migrated:  2014_10_12_000000_create_users_table
Migrating: 2014_10_12_100000_create_password_resets_table
Migrated:  2014_10_12_100000_create_password_resets_table
Migrating: 2018_08_18_071213_create_orders_table
Migrated:  2018_08_18_071213_create_orders_table
nishanth@localhost:~/Desktop/html/hutch$ 

Also define the method down(), if it doesn't exist.
Otherwise, it'll show

SQLSTATE[42S02]: Base table or view not found: 1051 Unknown table 'XYZ.ABC' (SQL: drop table ABC)

/**
  * Reverse the migrations.
  *
  * @return void
  */
public function down()
{
    Schema::dropIfExists('ABC');
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!