An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix indexing after deletion and make sure init script is removed form the server
peaklabs-dev7f393eb2c26c
diff --git a/app/Livewire/Project/Database/Postgresql/General.php b/app/Livewire/Project/Database/Postgresql/General.phpindex 3abdcc22e2..0180279120 100644--- a/app/Livewire/Project/Database/Postgresql/General.php+++ b/app/Livewire/Project/Database/Postgresql/General.php@@ -144,11 +144,13 @@ class General extends Component$initScripts->push($script);}- $this->database->init_scripts = $initScripts->values()->map(function ($item, $index) {- $item['index'] = $index;+ $this->database->init_scripts = $initScripts->values()+ ->map(function ($item, $index) {+ $item['index'] = $index;- return $item;- })->all();+ return $item;+ })+ ->all();$this->database->save();$this->dispatch('success', 'Init script saved.');@@ -159,12 +161,32 @@ class General extends Component$collection = collect($this->database->init_scripts);$found = $collection->firstWhere('filename', $script['filename']);if ($found) {- $this->database->init_scripts = $collection->filter(fn ($s) => $s['filename'] !== $script['filename'])->toArray();+ $container_name = $this->database->uuid;+ $configuration_dir = database_configuration_dir().'/'.$container_name;+ $file_path = "$configuration_dir/docker-entrypoint-initdb.d/{$script['filename']}";++ $command = "rm -f $file_path";+ try {+ instant_remote_process([$command], $this->server);+ } catch (\Exception $e) {+ $this->dispatch('error', 'Failed to remove init script from server: '.$e->getMessage());++ return;+ }++ $updatedScripts = $collection->filter(fn ($s) => $s['filename'] !== $script['filename'])+ ->values()+ ->map(function ($item, $index) {+ $item['index'] = $index;++ return $item;+ })+ ->all();++ $this->database->init_scripts = $updatedScripts;$this->database->save();$this->refresh();- $this->dispatch('success', 'Init script deleted.');-- return;+ $this->dispatch('success', 'Init script deleted from the database and the server.');}}diff --git a/resources/views/livewire/project/database/init-script.blade.php b/resources/views/livewire/project/database/init-script.blade.phpindex 8ba0db23c8..1580e41cca 100644--- a/resources/views/livewire/project/database/init-script.blade.php+++ b/resources/views/livewire/project/database/init-script.blade.php@@ -4,7 +4,7 @@<x-forms.button type="submit">Save</x-forms.button><x-modal-confirmation title="Confirm init-script deletion?" buttonTitle="Delete" isErrorButtonsubmitAction="delete" :actions="[- 'The init-script of this database will be permanently deleted.',+ 'The init-script of this database will be permanently deleted form the database and the server.','If you are actively using this init-script, it could cause errors on redeployment.',]" confirmationText="{{ $filename }}"confirmationLabel="Please confirm the execution of the actions by entering the init-script name below"