mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 16:04:32 -04:00
commit
74a56afe6d
@ -57,9 +57,16 @@ class ForceMigration extends Command
|
|||||||
{
|
{
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
$company = Company::where('plan', 'free')
|
$company = Company::on(DB_NINJA_1)
|
||||||
->with('accounts')
|
->whereNull('plan')
|
||||||
->first();
|
->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();
|
$user = $company->accounts->first()->users()->whereNull('public_id')->orWhere('public_id', 0)->first();
|
||||||
$db = DB_NINJA_1;
|
$db = DB_NINJA_1;
|
||||||
@ -71,10 +78,12 @@ class ForceMigration extends Command
|
|||||||
|
|
||||||
$data['companies'][$key]['id'] = $account->id;
|
$data['companies'][$key]['id'] = $account->id;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->dispatch(new HostedMigration($user, $data, $db, true));
|
$this->dispatch(new HostedMigration($user, $data, $db, true));
|
||||||
|
|
||||||
|
$company->is_migrated = true;
|
||||||
|
$company->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -443,6 +443,10 @@ trait GenerateMigrationResources
|
|||||||
foreach($agts as $agt) {
|
foreach($agts as $agt) {
|
||||||
|
|
||||||
$payment_method = $agt->default_payment_method;
|
$payment_method = $agt->default_payment_method;
|
||||||
|
|
||||||
|
if(!$payment_method)
|
||||||
|
continue;
|
||||||
|
|
||||||
$contact = Contact::where('id', $payment_method->contact_id)->withTrashed()->first();
|
$contact = Contact::where('id', $payment_method->contact_id)->withTrashed()->first();
|
||||||
|
|
||||||
$transformed[] = [
|
$transformed[] = [
|
||||||
@ -1631,6 +1635,9 @@ trait GenerateMigrationResources
|
|||||||
$contact = Contact::where('id', $payment_method->contact_id)->withTrashed()->first();
|
$contact = Contact::where('id', $payment_method->contact_id)->withTrashed()->first();
|
||||||
$agt = AccountGatewayToken::where('id', $payment_method->account_gateway_token_id)->withTrashed()->first();
|
$agt = AccountGatewayToken::where('id', $payment_method->account_gateway_token_id)->withTrashed()->first();
|
||||||
|
|
||||||
|
if(!$contact && !$agt)
|
||||||
|
continue;
|
||||||
|
|
||||||
$transformed[] = [
|
$transformed[] = [
|
||||||
'id' => $payment_method->id,
|
'id' => $payment_method->id,
|
||||||
'company_id' => $this->account->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…
x
Reference in New Issue
Block a user