mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
commit
74a56afe6d
@ -57,8 +57,15 @@ class ForceMigration extends Command
|
||||
{
|
||||
$data = [];
|
||||
|
||||
$company = Company::where('plan', 'free')
|
||||
$company = Company::on(DB_NINJA_1)
|
||||
->whereNull('plan')
|
||||
->orWhereIn('plan', ['','free'])
|
||||
->whereHas('accounts', function ($query){
|
||||
$query->where('account_key', 'NOT LIKE', substr(NINJA_ACCOUNT_KEY, 0, 30) . '%');
|
||||
})
|
||||
->with('accounts')
|
||||
->withCount('accounts')
|
||||
->having('accounts_count', '>=', 1)
|
||||
->first();
|
||||
|
||||
$user = $company->accounts->first()->users()->whereNull('public_id')->orWhere('public_id', 0)->first();
|
||||
@ -71,10 +78,12 @@ class ForceMigration extends Command
|
||||
|
||||
$data['companies'][$key]['id'] = $account->id;
|
||||
|
||||
|
||||
}
|
||||
|
||||
$this->dispatch(new HostedMigration($user, $data, $db, true));
|
||||
|
||||
$company->is_migrated = true;
|
||||
$company->save();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -443,6 +443,10 @@ trait GenerateMigrationResources
|
||||
foreach($agts as $agt) {
|
||||
|
||||
$payment_method = $agt->default_payment_method;
|
||||
|
||||
if(!$payment_method)
|
||||
continue;
|
||||
|
||||
$contact = Contact::where('id', $payment_method->contact_id)->withTrashed()->first();
|
||||
|
||||
$transformed[] = [
|
||||
@ -1631,6 +1635,9 @@ trait GenerateMigrationResources
|
||||
$contact = Contact::where('id', $payment_method->contact_id)->withTrashed()->first();
|
||||
$agt = AccountGatewayToken::where('id', $payment_method->account_gateway_token_id)->withTrashed()->first();
|
||||
|
||||
if(!$contact && !$agt)
|
||||
continue;
|
||||
|
||||
$transformed[] = [
|
||||
'id' => $payment_method->id,
|
||||
'company_id' => $this->account->id,
|
||||
|
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddMigrationFlagForCompaniesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('companies', function ($table) {
|
||||
$table->boolean('is_migrated')->default(false);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user