I created migration on my Laravel project using command php artisan make:migration migration_name
and php artisan make:model ModelName -mcr
.
When I run php artisan migrate
the output is nothing to migrate
.
I check my database, there is only migration
table which has no row, even user
table that comes from Laravel does not created.
This issue occurs on my laptop and PC
This is the environment that I use to run Laravel using XAMPP
This is the migration code
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
//File name = 2020_08_11_064146_create_category_table.php
//File Path = database/migrations
class CreateCategoryTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('category', function (Blueprint $table) {
$table->id();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('category');
}
}
I already try these but found no luck :
composer dump-autoload
php artisan migrate:reset
-> nothing to rollbackphp artisan migrate:fresh
-> dropped all table successfully, migration table created successfully ,nothing to migratephp artisan migrate --path="/database/migrations/"
-> nothing to migratephp artisan migrate:status
-> no migrations foundphp artisan migrate:install
-> Migration table create successfully, but did not solve the problemTLDR :
What I literally did are :
.env
for connection to database using user root
php artisan make:migration create_table_category
php artisan migrate
Migration table create successfully, nothing to migrate
. Database only have table migrations
with no rowsEDIT
Migration can be run if I specify the path completely with file name like php artisan migrate --path="database/migrations/2020_08_11_064146_create_category_table.php"
I stumbled into this post which described that the problems caused by project path that have character hyphens '-'
My project does not have those characters, but it has 'weird' characters and that is opening and closing square bracket '[ ]', so I thought to change it.
My root project directory path is F:\Indra\Kerja\[1] Personal\Personal profile\web
so my migration path is F:\Indra\Kerja\[1] Personal\Personal profile\web\database\migrations
Notice there's folder named [1] Personal
, that's the culprit
I renamed my folder to Personal
and voila the migration works normally.
I was curious so I try different folder name and I get and interesting result:
[asdasd]Personal
-> migration doesn't work for some reason[1 Personal
-> migration work]1Personal
-> migration work][1 Personal
-> migration work[]Personal
-> migration workSo I have to change my folder name
Important Note:
F:\Indra\Kerja\my-project-test
, and expect that the migration won't work, but the migration works without a problem