Add database overwrite checkbox on Install wizard

Allows overwriting the existing database when installing InvoiceShelf
This commit is contained in:
Darko Gjorgjijoski
2024-07-29 14:20:43 +02:00
parent 56a555bc4a
commit da600d0144
5 changed files with 18 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ use App\Http\Requests\DiskEnvironmentRequest;
use App\Http\Requests\DomainEnvironmentRequest; use App\Http\Requests\DomainEnvironmentRequest;
use App\Http\Requests\MailEnvironmentRequest; use App\Http\Requests\MailEnvironmentRequest;
use Exception; use Exception;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
class EnvironmentManager class EnvironmentManager
@@ -149,7 +150,9 @@ class EnvironmentManager
try { try {
$this->checkDatabaseConnection($request); $this->checkDatabaseConnection($request);
if ($request->get('database_overwrite')) {
Artisan::call('db:wipe --force');
}
if (\Schema::hasTable('users')) { if (\Schema::hasTable('users')) {
return [ return [
'error' => 'database_should_be_empty', 'error' => 'database_should_be_empty',

View File

@@ -1440,6 +1440,7 @@
"username": "Database Username", "username": "Database Username",
"db_name": "Database Name", "db_name": "Database Name",
"db_path": "Database Path", "db_path": "Database Path",
"overwrite": "Overwrite existing database and proceed",
"desc": "Create a database on your server and set the credentials using the form below." "desc": "Create a database on your server and set the credentials using the form below."
}, },
"permissions": { "permissions": {

View File

@@ -19,6 +19,7 @@ export const useInstallationStore = (useWindow = false) => {
database_name: null, database_name: null,
database_username: null, database_username: null,
database_password: null, database_password: null,
database_overwrite: false,
app_url: window.location.origin, app_url: window.location.origin,
app_locale: null app_locale: null
}, },

View File

@@ -84,6 +84,11 @@
:invalid="v$.database_hostname.$error" :invalid="v$.database_hostname.$error"
/> />
</BaseInputGroup> </BaseInputGroup>
</div>
<div class="w-full">
<BaseCheckbox v-model="databaseData.database_overwrite" :label="$t('wizard.database.overwrite')"/>
</div> </div>
<BaseButton <BaseButton
@@ -106,6 +111,8 @@ import { useInstallationStore } from '@/scripts/admin/stores/installation'
import { helpers, required, numeric } from '@vuelidate/validators' import { helpers, required, numeric } from '@vuelidate/validators'
import useVuelidate from '@vuelidate/core' import useVuelidate from '@vuelidate/core'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import BaseInputGroup from '@/scripts/components/base/BaseInputGroup.vue'
import BaseCheckbox from '@/scripts/components/base/BaseCheckbox.vue'
const props = defineProps({ const props = defineProps({
configData: { configData: {

View File

@@ -105,6 +105,10 @@
</BaseInputGroup> </BaseInputGroup>
</div> </div>
<div class="w-full">
<BaseCheckbox v-model="databaseData.database_overwrite" :label="$t('wizard.database.overwrite')"/>
</div>
<BaseButton <BaseButton
v-show="!isFetchingInitialData" v-show="!isFetchingInitialData"
:content-loading="isFetchingInitialData" :content-loading="isFetchingInitialData"
@@ -127,6 +131,7 @@ import { useInstallationStore } from '@/scripts/admin/stores/installation'
import { helpers, required, numeric } from '@vuelidate/validators' import { helpers, required, numeric } from '@vuelidate/validators'
import useVuelidate from '@vuelidate/core' import useVuelidate from '@vuelidate/core'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import BaseCheckbox from '@/scripts/components/base/BaseCheckbox.vue'
const props = defineProps({ const props = defineProps({
configData: { configData: {