first commit

This commit is contained in:
brusnitsyn
2026-03-23 00:51:38 +09:00
commit 07854e0a9d
110 changed files with 19528 additions and 0 deletions

View File

@@ -0,0 +1,100 @@
<?php
namespace App\Http\Controllers;
use App\Models\SourceDatabase;
use App\Models\Table;
use App\Models\Column;
use App\Services\SchemaExtractionService;
use App\Services\SchemaComparisonService;
use Illuminate\Http\Request;
use Inertia\Inertia;
class SchemaController extends Controller
{
public function __construct(
private SchemaExtractionService $extractionService,
private SchemaComparisonService $comparisonService
) {}
public function index()
{
$databases = SourceDatabase::with('tables')->get();
return Inertia::render('Schemas/Index', [
'databases' => $databases,
]);
}
public function show(SourceDatabase $database)
{
$database->load(['tables.columns', 'tables.indexes', 'tables.foreignKeys']);
return Inertia::render('Schemas/Show', [
'database' => $database,
]);
}
public function sync(SourceDatabase $database)
{
try {
$this->extractionService->saveSchema($database);
return redirect()->back()
->with('success', 'Schema synchronized successfully.');
} catch (\Exception $e) {
return redirect()->back()
->with('error', 'Failed to sync schema: ' . $e->getMessage());
}
}
public function checkChanges(SourceDatabase $database)
{
$changes = $this->comparisonService->checkForChanges($database);
return response()->json([
'success' => true,
'changes' => $changes,
]);
}
public function tableDetail(Table $table)
{
$table->load(['columns', 'indexes', 'foreignKeys', 'sourceDatabase']);
return Inertia::render('Schemas/TableDetail', [
'table' => $table,
]);
}
public function updateColumn(Request $request, Column $column)
{
$validated = $request->validate([
'target_column_name' => 'nullable|string|max:255',
'target_data_type' => 'nullable|string|max:100',
'exclude_from_migration' => 'boolean',
]);
$column->update($validated);
return redirect()->back()
->with('success', 'Column settings updated successfully.');
}
public function pendingChanges()
{
$changes = $this->comparisonService->getPendingChanges();
return Inertia::render('Schemas/PendingChanges', [
'changes' => $changes,
]);
}
public function applyChange(int $changeId)
{
$this->comparisonService->markAsApplied($changeId);
return redirect()->back()
->with('success', 'Schema change marked as applied.');
}
}