Avatar of Bruce Gust
Bruce Gust
Flag for United States of America

asked on 

Nothing to Migrate - My Journey into Larevel Purgatory

I'm trying to get things done quick.

I'm working on a Laravel project, I realize I need to alter the structure of a table so I just go into phpMyAdmin, do what needs to be done and then alter the corresponding migration file.

You're not supposed to do that, are you?

In the interest of keeping the migration file current, I just changed the schema. But then I began to wonder if that wasn't going to throw things off systemically and now, things are all cornfused.

First of all, just for the sake of my own edification: Migrations are not optional. Regardless of how incremental of a change you're making to your database, it all has to be done through the migration dynamic because that's a part of the way Larevel / Eloquent are processing things, correct?

Secondly, for the sake of cleaning up the mess i just described, here's what I did:

I created a "drop_video_table" migration and ran that successfully.
Here's the "create_videos_table" migration that I edited (perhaps incorrectly)

<?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');
			[b]$table->binary('description');
			$table->binary('filename');[/b]
                         $table->timestamps();
        });
    }

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

Open in new window


The part that I have in bold originally read:

$table-binary('code');

I changed that manually so it now is two additional fields.

Granted, I probably should've written an "alter_videos_table" migration, but lesson learned.

My dilemma is that when I go to run "$ php artisan migrate --path=database/migrations/2020_02_13_023156_create_videos_table.php," I get a message back that says, "Nothing to migrate."

OK, so I'm not going to try and pop the hood on phpMyAdmin again and alter my tables, but how do I get my new and improved videos table back on line?

Thanks!
LaravelPHP

Avatar of undefined
Last Comment
Bruce Gust

8/22/2022 - Mon