<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Api\SchemaController;

Route::get('/user', function (Request $request) {
    return $request->user();
})->middleware('auth:sanctum');

Route::prefix('schema')->group(function () {
    Route::get('/databases', [SchemaController::class, 'databases']);
    Route::post('/databases', [SchemaController::class, 'createDatabase']);
    Route::get('/tables/{database}', [SchemaController::class, 'tables']);
    Route::get('/metadata/{database}', [SchemaController::class, 'metadata']);
    Route::get('/metadata/{database}/tables', [SchemaController::class, 'tablesMetadata']);
    Route::get('/metadata/{database}/{table}', [SchemaController::class, 'tableMetadata']);
    Route::post('/truncate/{table}', [SchemaController::class, 'truncate']);
    Route::post('/drop/{table}', [SchemaController::class, 'drop']);
    Route::post('/optimize/{table}', [SchemaController::class, 'optimize']);
    Route::post('/bulk-action', [SchemaController::class, 'bulkAction']);
    Route::get('/{table}', [SchemaController::class, 'schema']);
    Route::get('/{table}/data', [SchemaController::class, 'data']);
    Route::post('/{table}/batch-update', [SchemaController::class, 'batchUpdate']);
    Route::post('/execute', [SchemaController::class, 'execute']);
    Route::post('/export', [SchemaController::class, 'export']);
    Route::post('/import', [SchemaController::class, 'import']);
});
