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

Updated company migration

This commit is contained in:
David Bomba 2024-08-05 08:56:31 +10:00
parent a2dc354e2c
commit 90eccfcaa0
2 changed files with 42 additions and 1 deletions

View File

@ -16,7 +16,7 @@ return new class extends Migration
// ->cursor()
// ->each(function($company){
// if($company->tax_data?->version == 'alpha')
// if($company->tax_data?->version == 'alpha' && ($company->tax_data->seller_subregion ?? false))
// {
// $company->update(['tax_data' => new \App\DataMapper\Tax\TaxModel($company->tax_data)]);

View File

@ -0,0 +1,41 @@
<?php
use App\Utils\Ninja;
use App\Models\Company;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
if(Ninja::isSelfHost())
{
Company::whereNotNull('tax_data')
->cursor()
->each(function ($company) {
if($company->tax_data?->version == 'alpha' && ($company->tax_data->seller_subregion ?? false)) {
$company->update(['tax_data' => new \App\DataMapper\Tax\TaxModel($company->tax_data)]);
}
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
//
}
};