feat: implement MySQL driver for database management and add TransferContent UI component
This commit is contained in:
@@ -96,9 +96,14 @@ class MySqlDriver implements DatabaseDriverInterface, SchemaDiscoveryInterface
|
||||
|
||||
public function export(array $config): string
|
||||
{
|
||||
$filename = 'backup-' . ($config['database'] ?? 'all') . '-' . date('Y-m-d-H-i-s') . '.sql';
|
||||
$directory = storage_path('app/backups');
|
||||
$database = $config['database'] ?? '';
|
||||
$table = $config['table'] ?? '';
|
||||
|
||||
$filename = !empty($table)
|
||||
? "{$table}-" . date('Y-m-d') . ".sql"
|
||||
: "backup-" . ($database ?: 'all') . "-" . date('Y-m-d') . ".sql";
|
||||
|
||||
$directory = storage_path('app/backups');
|
||||
if (!is_dir($directory)) {
|
||||
mkdir($directory, 0755, true);
|
||||
}
|
||||
@@ -108,13 +113,10 @@ class MySqlDriver implements DatabaseDriverInterface, SchemaDiscoveryInterface
|
||||
|
||||
$mysqldumpPath = env('MYSQLDUMP_PATH', 'mysqldump');
|
||||
|
||||
// Ensure we have a username
|
||||
$username = $config['username'] ?? 'root';
|
||||
$password = $config['password'] ?? '';
|
||||
$host = $config['host'] ?? '127.0.0.1';
|
||||
$port = $config['port'] ?? '3306';
|
||||
$database = $config['database'] ?? '';
|
||||
$table = $config['table'] ?? '';
|
||||
|
||||
// Build command with flags for a complete and resilient export
|
||||
$passwordPart = !empty($password) ? "-p" . escapeshellarg($password) : "";
|
||||
@@ -236,16 +238,16 @@ class MySqlDriver implements DatabaseDriverInterface, SchemaDiscoveryInterface
|
||||
{
|
||||
$sql = "
|
||||
SELECT
|
||||
ENGINE as engine,
|
||||
TABLE_ROWS as rows,
|
||||
DATA_LENGTH as data_length,
|
||||
INDEX_LENGTH as index_length,
|
||||
DATA_FREE as data_free,
|
||||
AUTO_INCREMENT as auto_increment,
|
||||
CREATE_TIME as create_time,
|
||||
UPDATE_TIME as update_time,
|
||||
TABLE_COLLATION as collation,
|
||||
TABLE_COMMENT as comment
|
||||
ENGINE as `engine`,
|
||||
TABLE_ROWS as `rows`,
|
||||
DATA_LENGTH as `data_length`,
|
||||
INDEX_LENGTH as `index_length`,
|
||||
DATA_FREE as `data_free`,
|
||||
AUTO_INCREMENT as `auto_increment`,
|
||||
CREATE_TIME as `create_time`,
|
||||
UPDATE_TIME as `update_time`,
|
||||
TABLE_COLLATION as `collation`,
|
||||
TABLE_COMMENT as `comment`
|
||||
FROM
|
||||
information_schema.TABLES
|
||||
WHERE
|
||||
|
||||
Reference in New Issue
Block a user