mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Migration improvements: (#3422)
- Added option to force the migration - Cleaned imports
This commit is contained in:
parent
bde276ad67
commit
67044f9dd3
@ -2,29 +2,29 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Migration;
|
namespace App\Http\Controllers\Migration;
|
||||||
|
|
||||||
use App\Http\Controllers\BaseController;
|
use App\Models\User;
|
||||||
use App\Http\Requests\MigrationAuthRequest;
|
|
||||||
use App\Http\Requests\MigrationCompaniesRequest;
|
|
||||||
use App\Http\Requests\MigrationEndpointRequest;
|
|
||||||
use App\Http\Requests\MigrationTypeRequest;
|
|
||||||
use App\Libraries\Utils;
|
|
||||||
use App\Models\AccountGateway;
|
|
||||||
use App\Models\AccountGatewaySettings;
|
|
||||||
use App\Models\AccountGatewayToken;
|
|
||||||
use App\Models\Contact;
|
|
||||||
use App\Models\Credit;
|
use App\Models\Credit;
|
||||||
use App\Models\Document;
|
use App\Models\Contact;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Models\PaymentMethod;
|
|
||||||
use App\Models\Product;
|
use App\Models\Product;
|
||||||
use App\Models\TaxRate;
|
use App\Models\TaxRate;
|
||||||
use App\Models\User;
|
use App\Libraries\Utils;
|
||||||
use App\Services\Migration\AuthService;
|
use App\Models\Document;
|
||||||
use App\Services\Migration\CompanyService;
|
use App\Models\PaymentMethod;
|
||||||
use App\Services\Migration\CompleteService;
|
use App\Models\AccountGateway;
|
||||||
|
use App\Models\AccountGatewayToken;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Crypt;
|
use Illuminate\Support\Facades\Crypt;
|
||||||
|
use App\Models\AccountGatewaySettings;
|
||||||
|
use App\Services\Migration\AuthService;
|
||||||
|
use App\Http\Controllers\BaseController;
|
||||||
|
use App\Services\Migration\CompanyService;
|
||||||
|
use App\Http\Requests\MigrationAuthRequest;
|
||||||
|
use App\Http\Requests\MigrationTypeRequest;
|
||||||
|
use App\Services\Migration\CompleteService;
|
||||||
|
use App\Http\Requests\MigrationEndpointRequest;
|
||||||
|
use App\Http\Requests\MigrationCompaniesRequest;
|
||||||
|
|
||||||
class StepsController extends BaseController
|
class StepsController extends BaseController
|
||||||
{
|
{
|
||||||
@ -147,7 +147,8 @@ class StepsController extends BaseController
|
|||||||
foreach ($request->companies as $company) {
|
foreach ($request->companies as $company) {
|
||||||
$completeService = (new CompleteService(session('MIGRATION_ACCOUNT_TOKEN')))
|
$completeService = (new CompleteService(session('MIGRATION_ACCOUNT_TOKEN')))
|
||||||
->file($this->getMigrationFile())
|
->file($this->getMigrationFile())
|
||||||
->company($company)
|
->force(array_key_exists('force', $company))
|
||||||
|
->company($company['id'])
|
||||||
->endpoint(session('MIGRATION_ENDPOINT'))
|
->endpoint(session('MIGRATION_ENDPOINT'))
|
||||||
->start();
|
->start();
|
||||||
}
|
}
|
||||||
@ -257,9 +258,6 @@ class StepsController extends BaseController
|
|||||||
|
|
||||||
public function getCompanySettings()
|
public function getCompanySettings()
|
||||||
{
|
{
|
||||||
// In v1: custom_invoice_taxes1 & custom_invoice_taxes2, v2: 'invoice_taxes'. What do to with this?
|
|
||||||
// V1: invoice_number_prefix, v2: invoice_number_pattern.. same with quote_number, client_number,
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'timezone_id' => $this->account->timezone_id ? (string)$this->account->timezone_id : '15',
|
'timezone_id' => $this->account->timezone_id ? (string)$this->account->timezone_id : '15',
|
||||||
'date_format_id' => $this->account->date_format_id ? (string)$this->account->date_format_id : '1',
|
'date_format_id' => $this->account->date_format_id ? (string)$this->account->date_format_id : '1',
|
||||||
|
@ -15,6 +15,7 @@ class CompleteService
|
|||||||
protected $uri = '/api/v1/migration/start/';
|
protected $uri = '/api/v1/migration/start/';
|
||||||
protected $errors = [];
|
protected $errors = [];
|
||||||
protected $isSuccessful;
|
protected $isSuccessful;
|
||||||
|
protected $force = false;
|
||||||
|
|
||||||
|
|
||||||
public function __construct(string $token)
|
public function __construct(string $token)
|
||||||
@ -29,6 +30,13 @@ class CompleteService
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function force($option)
|
||||||
|
{
|
||||||
|
$this->force = $option;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function company($company)
|
public function company($company)
|
||||||
{
|
{
|
||||||
$this->company = $company;
|
$this->company = $company;
|
||||||
@ -47,6 +55,7 @@ class CompleteService
|
|||||||
{
|
{
|
||||||
$body = [
|
$body = [
|
||||||
'migration' => \Unirest\Request\Body::file($this->file, 'application/zip'),
|
'migration' => \Unirest\Request\Body::file($this->file, 'application/zip'),
|
||||||
|
'force' => $this->force,
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = Request::post($this->getUrl(), $this->getHeaders(), $body);
|
$response = Request::post($this->getUrl(), $this->getHeaders(), $body);
|
||||||
|
@ -17,11 +17,16 @@
|
|||||||
|
|
||||||
@foreach($companies as $company)
|
@foreach($companies as $company)
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input class="form-check-input" type="checkbox" name="companies[]" id="company1" value="{{ $company->id }}" checked>
|
<input class="form-check-input" type="checkbox" name="companies[{{ $company->id }}][id]" id="company1" value="{{ $company->id }}" checked>
|
||||||
<label class="form-check-label" for="company1">
|
<label class="form-check-label" for="company1">
|
||||||
Name: {{ $company->settings->name }} ID: {{ $company->id }}
|
Name: {{ $company->settings->name }} ID: {{ $company->id }}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<input type="checkbox" name="companies[{{ $company->id }}][force]">
|
||||||
|
<label for="force">Force migration</label>
|
||||||
|
<small>* All current company data will be wiped.</small>
|
||||||
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user