1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00
invoiceninja/database/migrations/2016_04_23_182223_payments_changes.php

73 lines
2.1 KiB
PHP
Raw Normal View History

2016-04-23 22:40:19 +02:00
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class PaymentsChanges extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::dropIfExists('payment_statuses');
Schema::create('payment_statuses', function($table)
{
$table->increments('id');
$table->string('name');
});
(new \PaymentStatusSeeder())->run();
Schema::table('payments', function($table)
{
$table->decimal('refunded', 13, 2);
2016-05-06 23:05:42 +02:00
$table->unsignedInteger('payment_status_id')->default(PAYMENT_STATUS_COMPLETED);
2016-04-23 22:40:19 +02:00
$table->foreign('payment_status_id')->references('id')->on('payment_statuses');
$table->unsignedInteger('routing_number')->nullable();
$table->smallInteger('last4')->unsigned()->nullable();
$table->date('expiration')->nullable();
2016-04-30 23:54:56 +02:00
$table->text('gateway_error')->nullable();
2016-04-23 22:40:19 +02:00
});
Schema::table('invoices', function($table)
{
$table->tinyInteger('enable_auto_bill')->default(AUTO_BILL_OFF);
});
\DB::table('invoices')
->where('auto_bill', '=', 1)
->update(array('enable_auto_bill' => AUTO_BILL_OPT_OUT));
2016-04-23 22:40:19 +02:00
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('payments', function($table)
{
$table->dropColumn('refunded');
$table->dropForeign('payments_payment_status_id_foreign');
$table->dropColumn('payment_status_id');
$table->dropColumn('routing_number');
$table->dropColumn('last4');
$table->dropColumn('expiration');
2016-04-30 23:54:56 +02:00
$table->dropColumn('gateway_error');
2016-04-23 22:40:19 +02:00
});
Schema::table('invoices', function ($table) {
$table->dropColumn('enable_auto_bill');
});
2016-04-23 22:40:19 +02:00
Schema::dropIfExists('payment_statuses');
}
}