Export 'company_key' with migrations (#3600)

- Removed 'Hosted' option for migrating
- Passing companyKey property when sending request
This commit is contained in:
Benjamin Beganović 2020-04-07 22:43:20 +02:00 committed by GitHub
parent 0c7620a381
commit 602a15f648
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 6 deletions

View File

@ -155,11 +155,12 @@ class StepsController extends BaseController
return redirect($this->access['companies']['redirect']);
foreach ($request->companies as $company) {
$completeService = (new CompleteService(session('MIGRATION_ACCOUNT_TOKEN')))
(new CompleteService(session('MIGRATION_ACCOUNT_TOKEN')))
->file($this->getMigrationFile())
->force(array_key_exists('force', $company))
->company($company['id'])
->endpoint(session('MIGRATION_ENDPOINT'))
->companyKey($company['key'])
->start();
}
@ -223,7 +224,7 @@ class StepsController extends BaseController
'client_gateway_tokens' => $this->getClientGatewayTokens(),
];
$file = storage_path("{$fileName}.zip");
$file = storage_path("migrations/{$fileName}.zip");
$zip = new \ZipArchive();
$zip->open($file, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);

View File

@ -16,7 +16,7 @@ class CompleteService
protected $errors = [];
protected $isSuccessful;
protected $force = false;
protected $companyKey;
public function __construct(string $token)
{
@ -51,11 +51,19 @@ class CompleteService
return $this;
}
public function companyKey(string $key)
{
$this->companyKey = $key;
return $this;
}
public function start()
{
$body = [
'migration' => \Unirest\Request\Body::file($this->file, 'application/zip'),
'force' => $this->force,
'company_key' => $this->companyKey,
];
$response = Request::post($this->getUrl(), $this->getHeaders(), $body);

View File

@ -24,6 +24,7 @@
</div>
<div class="form-group">
<input type="checkbox" name="companies[{{ $company->id }}][force]">
<input type="hidden" name="companies[{{ $company->id }}][key]" value="{{ $company->company_key }}">
<label for="force">Force migration</label>
<small>* All current company data will be wiped.</small>
</div>

View File

@ -12,15 +12,15 @@
<h4>In order to start the migration, we need to know where do you want to migrate.</h4><br/>
<form action="/migration/type" method="post" id="select-type-form">
{{ csrf_field() }}
<div class="form-check">
<!-- <div class="form-check">
<input class="form-check-input" type="radio" name="option" id="option1" value="0" checked>
<label class="form-check-label" for="option1">
Hosted
</label>
<p>If you chose 'hosted', we will migrate your data to official Invoice Ninja servers & take care of server handling.</p>
</div>
</div> -->
<div class="form-check">
<input class="form-check-input" type="radio" name="option" id="option2" value="1">
<input class="form-check-input" type="radio" name="option" id="option2" value="1" checked">
<label class="form-check-label" for="option2">
Self-hosted
</label>