1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 00:11:35 +02:00
invoiceninja/database/migrations/2022_07_29_091235_correction_for_companies_table_types.php
2023-02-16 12:36:09 +11:00

36 lines
825 B
PHP

<?php
use App\Models\Company;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('companies', function (Blueprint $table) {
$table->unsignedInteger('enabled_expense_tax_rates')->default(0)->change();
});
Company::query()->where('enabled_item_tax_rates', true)->cursor()->each(function ($company) {
$company->enabled_expense_tax_rates = $company->enabled_item_tax_rates;
$company->save();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
};