I have an existing database table and I want to add column on it. However, as I run the php artisan migrate
command, it says nothing to migrate. But I already add a Schema for adding table columns. I have read some articles and links that I should run the php artisan migrate:refresh
first before the new columns to be added.The problem is, it will erase my existing data in my table. Is there any way I could perform the migration and successfully add columns in my table without deleting my data? Please help me with this. Thanks a lot. Here is my migration code.
public function up()
{
//
Schema::create('purchase_orders', function(Blueprint $table){
$table->increments('id');
$table->string('po_code');
$table->text('purchase_orders');
$table->float('freight_charge');
$table->float('overall_total');
$table->timestamps();
});
Schema::table('purchase_orders', function(Blueprint $table){
$table->string('shipped_via');
$table->string('terms');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
Schema::drop('purchase_orders');
}
I want to add column shipped_via
and terms
in my purchase_orders
table.