Are the files in a sub folder by any chance? The command will only look at the root of the migrations directory
The `php artisan migrate` is not working
Good day, I don't know what to do about this problem, I searched on the internet and I found nothing. When I php artisan migrate, it only created a migrations table in my database. It doesn't include the files in the migrations folder.
This is the response when I php artisan migrate,
Migration table created successfully.
Nothing to migrate.
@rmmlcny can you post an example of one of the migration files in the database/migrations directory that does not run?
@tykus all the files in the database/migrations does not run, It's the default migration files when creating new Laravel 8 project.
2014_10_12_000000_create_users_table.php
2014_10_12_100000_create_password_resets_table.php
2019_08_19_000000_create_failed_jobs_table.php
2019_12_14_000001_create_personal_access_tokens_table.php
@rmmlcny what do you get if you run php artisan migrate:status
@rmmlcny oh?!?!
If you execute php artisan migrate:status; does the command output even show these migration files as not ran?
@Sinnbeck Oh my, its No migrations found.
@rmmlcny is this a completely vanilla Laravel 8 project?? Or, has someone modified the default migrations path in (for example) a Service Provider?
@tykus It's completely vanilla, I did multiple installations of new Laravel project but it's still the same problem.
Can you try to force the migrations path?
php artisan migrate --path=database/migrations
@tykus It didn't work. It says Nothing to migrate.
@rmmlcny what is your database configuration?
@tykus The .env file?
@rmmlcny I meant generally.
Can you check your logs as well?
I used mysql, and is running in a host 127.0.0.1 with port 3306.
I don't know where to check the logs, but I checked the logs/laravel.log, if I'm correct. One of the message shown here is:
[2022-01-20 12:00:12] local.ERROR: No arguments expected for "migrate" command, got "C:/Program Files/Git/database/migrations/2014_10_12_000000_create_users_table". {"exception":"[object] (Symfony\\Component\\Console\\Exception\\RuntimeException(code: 0): No arguments expected for \"migrate\" command, got \"C:/Program Files/Git/database/migrations/2014_10_12_000000_create_users_table\". at G:\\[My stuff]\\- Practice code\\Laravel\\example-app\\vendor\\symfony\\console\\Input\\ArgvInput.php:193)
@rmmlcny I suppose that was from earlier?
@tykus yeah
@rmmlcny I'm stumped. I would start by source diving adding temporary dds in the MigrateCommand (and beyond) to see if it is finding the migration files at all; checking paths etc.
To be honest, this is such a basic feature of the framework; I would be surprised if the issue was with the laravel framework. You could try again in a completely new Laravel project; then with a SQLite database instead of mysql - something/anything to change the outcome(s)...
@rmmlcny why it is inside "C:/Program Files/Git/"? How about you try work on other none system directory instead of c:\program files, say d:\projects? How about you use the artisan command to create a new migration file and execute the migrate command again, will it migrate?
@siangboon Oh my God, thank you. So basically, I stored my project in the other drive which was the 'G:' drive and I tried to move it in the 'C:' drive, now it works. HOOOH! It took me 1 day to found the solution.
open tinker. check if migrations is indeed empty
>>> DB::table('migrations')->get()
I'm wondering if you are connected to a different database
You can also check
>>> config('database')
@Snapey I got empty in migrations
Illuminate\Support\Collection {#3508
all: [],
}
In the config('database') , I got
[
"default" => "mysql",
"connections" => [
"sqlite" => [
"driver" => "sqlite",
"url" => null,
"database" => "example",
"prefix" => "",
"foreign_key_constraints" => true,
],
"mysql" => [
"driver" => "mysql",
"url" => null,
"host" => "127.0.0.1",
"port" => "3306",
"database" => "example",
"username" => "root",
"password" => "",
"unix_socket" => "",
"charset" => "utf8mb4",
"collation" => "utf8mb4_unicode_ci",
"prefix" => "",
"prefix_indexes" => true,
"strict" => true,
"engine" => null,
"options" => [],
],
"pgsql" => [
"driver" => "pgsql",
"url" => null,
"host" => "127.0.0.1",
"port" => "3306",
"database" => "example",
"username" => "root",
"password" => "",
"charset" => "utf8",
"prefix" => "",
"prefix_indexes" => true,
"schema" => "public",
"sslmode" => "prefer",
],
"sqlsrv" => [
"driver" => "sqlsrv",
"url" => null,
"host" => "127.0.0.1",
"port" => "3306",
"database" => "example",
"username" => "root",
"password" => "",
"charset" => "utf8",
"prefix" => "",
"prefix_indexes" => true,
],
],
"migrations" => "migrations",
"redis" => [
"client" => "phpredis",
"options" => [
"cluster" => "redis",
"prefix" => "laravel_database_",
],
"default" => [
"url" => null,
"host" => "127.0.0.1",
"password" => null,
"port" => "6379",
"database" => "0",
],
"cache" => [
"url" => null,
"host" => "127.0.0.1",
"password" => null,
"port" => "6379",
"database" => "1",
],
],
]
I have same problem, artisan migrate create only migration table. And it take hours to figure it out, so i found answer on other site, but solution in my came, in my project path in folder name was brackets like this [] so i delete them and it start work
@SardarDev Wow, would never have found that, big thanks!
Please or to participate in this conversation.