v1.2.0 update column issue

This commit is contained in:
cuneytsenturk 2018-05-01 13:09:47 +03:00
parent b96ccc876e
commit a6f24cf3b1
2 changed files with 28 additions and 38 deletions

View File

@ -9,6 +9,8 @@ use App\Models\Company\Company;
use App\Models\Expense\Bill;
use App\Models\Income\Invoice;
use App\Models\Setting\Category;
use DB;
use Schema;
use Artisan;
class Version120 extends Listener
@ -36,6 +38,8 @@ class Version120 extends Listener
Artisan::call('migrate', ['--force' => true]);
$this->updateInvoicesAndBills();
$this->changeQuantityColumn();
}
protected function updatePermissions()
@ -106,4 +110,28 @@ class Version120 extends Listener
}
}
}
protected function changeQuantityColumn()
{
$connection = env('DB_CONNECTION');
if ($connection == 'mysql') {
$tables = [
env('DB_PREFIX') . 'invoice_items',
env('DB_PREFIX') . 'bill_items'
];
foreach ($tables as $table) {
DB::statement("ALTER TABLE `$table` MODIFY `quantity` DOUBLE(7,2) NOT NULL");
}
} else {
Schema::table('invoice_items', function ($table) {
$table->decimal('quantity', 7, 2)->change();
});
Schema::table('bill_items', function ($table) {
$table->decimal('quantity', 7, 2)->change();
});
}
}
}

View File

@ -1,38 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
class ChangeQuantityColumnInvoiceBillItems extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('invoice_items', function ($table) {
$table->double('quantity', 7, 2)->change();
});
Schema::table('bill_items', function ($table) {
$table->double('quantity', 7, 2)->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('invoice_items', function ($table) {
$table->integer('quantity')->change();
});
Schema::table('bill_items', function ($table) {
$table->integer('quantity')->change();
});
}
}