I have read Laravel's documentation and other forums but it just doesn't work on me. I have successfully migrated a table, now I wanted add a field, changed the schema to 'table' but all I get is 'Nothing to migrate'.
Here is what I've done.
Migration:
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateProductTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('product', function(Blueprint $table)
{
$table->text('image');
$table->integer('stock');
$table->integer('amount');
$table->string('color');
$table->string('dimension');
$table->integer('ordered');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('product');
}
}
Then, run the command php artisan migrate, and all is well.
Then I decided to add new field, so I changed the controller to this:
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateProductTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('product', function(Blueprint $table)
{
$table->increments('id');
$table->string('name');
$table->text('description');
$table->text('image'); //new
$table->int('active'); //new
$table->integer('stock');
$table->integer('amount');
$table->string('color');
$table->string('dimension');
$table->integer('ordered');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('product');
}
}
then run php artisan migrate again but I only get Nothing to migrate.
I also removed Blueprint, that didn't work as well. migrate:refresh and migrate:reset does the job but that is not what I want as it also removes the data.