We help IT Professionals succeed at work.

Why does this migration process not create a table in the database?

Bruce Gust
Bruce Gust asked
on
I'm creating a table in Laravel. I created both my Model and my Migration using:

php artisan make:model Video -m

That resulted in a new Migration file called, "2020_02_13_023156_create_videos_table.php" which looks like this:

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateVideosTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('videos', function (Blueprint $table) {
            $table->bigIncrements('id');
			$table->string('title');
			$table->binary('code');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('videos');
    }
}

Open in new window


Perfect!

Now, I want to add that table to the database, so I run this:

$ php artisan migrate --path=database/migrations/2020_02_13_023156_create_videos_table

...and I get an error that says, "Nothing to migrate."

So, I'm looking at what appears to be a sound approach, but there's no "videos" table in the databsae.

What am I missing?
Comment
Watch Question

NorieAnalyst Assistant

Commented:
Bruce

What happens if you try without the path?
php artisan migrate

Open in new window

Most Valuable Expert 2018
Distinguished Expert 2019

Commented:
Hey Bruce,

You're missing the php extension from your migrtion file:

php artisan migrate --path=database/migrations/2020_02_13_023156_create_videos_table.php
Bruce GustPHP Developer

Author

Commented:
Chris, I swear to you that the example I found on Google looked like it had intentionally left out the extension. I'll give it a shot when I get back to the house.

Thanks!
Most Valuable Expert 2018
Distinguished Expert 2019

Commented:
Haha - got to love Google ;)
Bruce GustPHP Developer

Author

Commented:
That did it, Chris!

Four characters and BOOM - there's the table!

Thanks!
Most Valuable Expert 2018
Distinguished Expert 2019
Good stuff. The reason it showed "Nothing to Migrate" without the .php is because it's thinking you meant a folder, not a file, so it was trying to run all the migrations within the 2020_02_13_023156_create_videos_table folder.
Bruce GustPHP Developer

Author

Commented:
Thank you!