v1.2.0 update column issue
This commit is contained in:
parent
b96ccc876e
commit
a6f24cf3b1
@ -9,6 +9,8 @@ use App\Models\Company\Company;
|
|||||||
use App\Models\Expense\Bill;
|
use App\Models\Expense\Bill;
|
||||||
use App\Models\Income\Invoice;
|
use App\Models\Income\Invoice;
|
||||||
use App\Models\Setting\Category;
|
use App\Models\Setting\Category;
|
||||||
|
use DB;
|
||||||
|
use Schema;
|
||||||
use Artisan;
|
use Artisan;
|
||||||
|
|
||||||
class Version120 extends Listener
|
class Version120 extends Listener
|
||||||
@ -36,6 +38,8 @@ class Version120 extends Listener
|
|||||||
Artisan::call('migrate', ['--force' => true]);
|
Artisan::call('migrate', ['--force' => true]);
|
||||||
|
|
||||||
$this->updateInvoicesAndBills();
|
$this->updateInvoicesAndBills();
|
||||||
|
|
||||||
|
$this->changeQuantityColumn();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function updatePermissions()
|
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();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user