mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-19 18:01:37 +00:00
fix: allow reuse of a database name (#571)
* fix: allow reuse of a database name * style --------- Co-authored-by: Saeed Vaziry <61919774+saeedvaziry@users.noreply.github.com> Co-authored-by: Saeed Vaziry <mr.saeedvaziry@gmail.com>
This commit is contained in:
parent
f3500497d0
commit
4e5f975917
@ -53,7 +53,7 @@ public static function rules(Server $server, array $input): array
|
|||||||
'name' => [
|
'name' => [
|
||||||
'required',
|
'required',
|
||||||
'alpha_dash',
|
'alpha_dash',
|
||||||
Rule::unique('databases', 'name')->where('server_id', $server->id),
|
Rule::unique('databases', 'name')->where('server_id', $server->id)->whereNull('deleted_at'),
|
||||||
],
|
],
|
||||||
'charset' => [
|
'charset' => [
|
||||||
'required',
|
'required',
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Actions\Database;
|
namespace App\Actions\Database;
|
||||||
|
|
||||||
|
use App\Models\Backup;
|
||||||
use App\Models\Database;
|
use App\Models\Database;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use App\Models\Service;
|
use App\Models\Service;
|
||||||
@ -16,5 +17,9 @@ public function delete(Server $server, Database $database): void
|
|||||||
$handler = $service->handler();
|
$handler = $service->handler();
|
||||||
$handler->delete($database->name);
|
$handler->delete($database->name);
|
||||||
$database->delete();
|
$database->delete();
|
||||||
|
|
||||||
|
$database->backups()->each(function (Backup $backup): void {
|
||||||
|
app(ManageBackup::class)->stop($backup);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,4 +100,10 @@ public static function rules(Server $server, array $input): array
|
|||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function stop(Backup $backup): void
|
||||||
|
{
|
||||||
|
$backup->status = BackupStatus::STOPPED;
|
||||||
|
$backup->save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,4 +9,6 @@ final class BackupStatus
|
|||||||
const FAILED = 'failed';
|
const FAILED = 'failed';
|
||||||
|
|
||||||
const DELETING = 'deleting';
|
const DELETING = 'deleting';
|
||||||
|
|
||||||
|
const STOPPED = 'stopped';
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,7 @@ public static function boot(): void
|
|||||||
BackupStatus::RUNNING => 'success',
|
BackupStatus::RUNNING => 'success',
|
||||||
BackupStatus::FAILED => 'danger',
|
BackupStatus::FAILED => 'danger',
|
||||||
BackupStatus::DELETING => 'warning',
|
BackupStatus::DELETING => 'warning',
|
||||||
|
BackupStatus::STOPPED => 'danger',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function isCustomInterval(): bool
|
public function isCustomInterval(): bool
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
* @property string $status
|
* @property string $status
|
||||||
* @property Server $server
|
* @property Server $server
|
||||||
* @property Backup[] $backups
|
* @property Backup[] $backups
|
||||||
* @property Carbon $deleted_at
|
* @property ?Carbon $deleted_at
|
||||||
*/
|
*/
|
||||||
class Database extends AbstractModel
|
class Database extends AbstractModel
|
||||||
{
|
{
|
||||||
|
@ -40,6 +40,7 @@ protected function getTableColumns(): array
|
|||||||
return [
|
return [
|
||||||
TextColumn::make('database.name')
|
TextColumn::make('database.name')
|
||||||
->label('Database')
|
->label('Database')
|
||||||
|
->tooltip(fn (Backup $record) => $record->database->deleted_at ? 'Deleted at '.$record->database->deleted_at->format('Y-m-d H:i:s') : null)
|
||||||
->searchable(),
|
->searchable(),
|
||||||
TextColumn::make('storage.profile')
|
TextColumn::make('storage.profile')
|
||||||
->label('Storage')
|
->label('Storage')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user