mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-09 12:42:36 +01:00
commit
dbc0ba02fc
@ -17,7 +17,7 @@ class ExportMigrations extends Command
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'migrations:export {--user=} {--random=}';
|
protected $signature = 'migrations:export {--user=} {--email=} {--random=}';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The console command description.
|
* The console command description.
|
||||||
@ -46,8 +46,36 @@ class ExportMigrations extends Command
|
|||||||
$this->info('Note: Migrations will be stored inside of (storage/migrations) folder.');
|
$this->info('Note: Migrations will be stored inside of (storage/migrations) folder.');
|
||||||
|
|
||||||
if($this->option('user')) {
|
if($this->option('user')) {
|
||||||
$record = User::findOrFail($this->option('user'));
|
$record = User::on(DB_NINJA_1)->find($this->option('user'));
|
||||||
|
|
||||||
|
if($record)
|
||||||
return $this->export($record);
|
return $this->export($record);
|
||||||
|
|
||||||
|
$record = User::on(DB_NINJA_2)->find($this->option('user'));
|
||||||
|
|
||||||
|
if($record)
|
||||||
|
return $this->export($record);
|
||||||
|
|
||||||
|
|
||||||
|
$this->info('I could not find that user - sorry');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if($this->option('email')) {
|
||||||
|
$record = User::on(DB_NINJA_1)->where('email', $this->option('user'))->first();
|
||||||
|
|
||||||
|
if($record)
|
||||||
|
return $this->export($record);
|
||||||
|
|
||||||
|
$record = User::on(DB_NINJA_2)->where('email', $this->option('user'))->first();
|
||||||
|
|
||||||
|
if($record)
|
||||||
|
return $this->export($record);
|
||||||
|
|
||||||
|
|
||||||
|
$this->info('I could not find that user by email - sorry');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->option('random')){
|
if($this->option('random')){
|
||||||
|
81
app/Console/Commands/ForceMigration.php
Normal file
81
app/Console/Commands/ForceMigration.php
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Jobs\HostedMigration;
|
||||||
|
use App\Libraries\Utils;
|
||||||
|
use App\Models\Company;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class ForceMigration extends Command
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'ninja:force-migrate-v5';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Force migrate accounts to v5 - (Hosted function only)';
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(!Utils::isNinjaProd())
|
||||||
|
return;
|
||||||
|
|
||||||
|
config(['database.default' => DB_NINJA_1]);
|
||||||
|
|
||||||
|
$this->forceMigrate();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function forceMigrate()
|
||||||
|
{
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
$company = Company::where('plan', 'free')
|
||||||
|
->with('accounts')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$user = $company->accounts->first()->users()->whereNull('public_id')->orWhere('public_id', 0)->first();
|
||||||
|
$db = DB_NINJA_1;
|
||||||
|
|
||||||
|
if($company){
|
||||||
|
|
||||||
|
foreach($company->accounts as $key => $account)
|
||||||
|
{
|
||||||
|
|
||||||
|
$data['companies'][$key]['id'] = $account->id;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->dispatch(new HostedMigration($user, $data, $db, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -65,6 +65,11 @@ class Kernel extends ConsoleKernel
|
|||||||
->withoutOverlapping()
|
->withoutOverlapping()
|
||||||
->daily();
|
->daily();
|
||||||
|
|
||||||
|
|
||||||
|
// $schedule
|
||||||
|
// ->command('ninja:force-migrate-v5')
|
||||||
|
// ->everyMinute()
|
||||||
|
// ->withoutOverlapping();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,11 +25,14 @@ class HostedMigration extends Job
|
|||||||
|
|
||||||
public $migration_token;
|
public $migration_token;
|
||||||
|
|
||||||
public function __construct(User $user, array $data, $db)
|
private $forced;
|
||||||
|
|
||||||
|
public function __construct(User $user, array $data, $db, $forced = false)
|
||||||
{
|
{
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
$this->data = $data;
|
$this->data = $data;
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
|
$this->forced = $forced;
|
||||||
$this->v4_secret = config('ninja.ninja_hosted_secret');
|
$this->v4_secret = config('ninja.ninja_hosted_secret');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,6 +109,17 @@ class HostedMigration extends Job
|
|||||||
|
|
||||||
$this->account = $account;
|
$this->account = $account;
|
||||||
|
|
||||||
|
if($this->forced){
|
||||||
|
//forced migration - we need to set this v4 account as inactive.
|
||||||
|
|
||||||
|
//set activate URL
|
||||||
|
$account_email_settings = $this->account->account_email_settings;
|
||||||
|
$account_email_settings->account_email_settings->forward_url_for_v5 = "https://invoiceninja-{$this->account->id}.invoicing.co";
|
||||||
|
$account_email_settings->save();
|
||||||
|
|
||||||
|
$this->account->subdomain = "invoiceninja-{$this->account->id}";
|
||||||
|
}
|
||||||
|
|
||||||
$date = date('Y-m-d');
|
$date = date('Y-m-d');
|
||||||
$accountKey = $this->account->account_key;
|
$accountKey = $this->account->account_key;
|
||||||
|
|
||||||
|
@ -2015,8 +2015,8 @@ trait GenerateMigrationResources
|
|||||||
}
|
}
|
||||||
|
|
||||||
$fees_and_limits = new \stdClass();
|
$fees_and_limits = new \stdClass();
|
||||||
$fees_and_limits->min_limit = $ags->min_limit;
|
$fees_and_limits->min_limit = $ags->min_limit ?: -1;
|
||||||
$fees_and_limits->max_limit = $ags->max_limit;
|
$fees_and_limits->max_limit = $ags->max_limit ?: -1;
|
||||||
$fees_and_limits->fee_amount = $ags->fee_amount;
|
$fees_and_limits->fee_amount = $ags->fee_amount;
|
||||||
$fees_and_limits->fee_percent = $ags->fee_percent;
|
$fees_and_limits->fee_percent = $ags->fee_percent;
|
||||||
$fees_and_limits->fee_tax_name1 = $ags->tax_name1;
|
$fees_and_limits->fee_tax_name1 = $ags->tax_name1;
|
||||||
|
Loading…
Reference in New Issue
Block a user