feat: implement database management API with MySQL driver and schema operations

This commit is contained in:
Ümit Tunç
2026-04-28 20:19:56 +03:00
parent 2e529bb61c
commit 01ddb81aa9
7 changed files with 276 additions and 9 deletions
@@ -287,4 +287,31 @@ class SchemaController extends Controller
return Response::json(['error' => $e->getMessage()], 400);
}
}
public function dropDatabase(Request $request, $database)
{
try {
$this->initializeDriver($request);
$this->databaseService->dropDatabase($database);
return Response::json(['message' => "Database '{$database}' dropped successfully"]);
} catch (\Exception $e) {
return Response::json(['error' => $e->getMessage()], 400);
}
}
public function renameDatabase(Request $request, $database)
{
$request->validate([
'newName' => 'required|string|max:64',
]);
try {
$this->initializeDriver($request);
$newName = $request->get('newName');
$this->databaseService->renameDatabase($database, $newName);
return Response::json(['message' => "Database '{$database}' renamed to '{$newName}' successfully"]);
} catch (\Exception $e) {
return Response::json(['error' => $e->getMessage()], 400);
}
}
}