This commit is contained in:
Duidev Software House
2025-10-12 23:06:46 +07:00
parent bf4093e01d
commit 684705b383
1405 changed files with 273 additions and 254420 deletions
@@ -13,17 +13,37 @@ class JsonTransferController extends Controller
public function index()
{
$tables = DB::select("SELECT tablename FROM pg_tables WHERE schemaname = 'public'");
$tableNames = array_map(fn($t) => $t->tablename, $tables);
//POSTGRESS
//$tables = DB::select("SELECT tablename FROM pg_tables WHERE schemaname = 'public'");
//$tableNames = array_map(fn($t) => $t->tablename, $tables);
//MYSQL
$tables = DB::select('SHOW TABLES');
$tableNames = array_map('current', $tables);
$tableInfo = [];
return view('backup', compact('tableNames'));
foreach ($tableNames as $table) {
$filePath = base_path($this->exportPath . $table . '.json');
$fileSize = file_exists($filePath) ? filesize($filePath) : null;
$tableInfo[] = [
'name' => $table,
'size' => $fileSize,
];
}
return view('backup', compact('tableInfo'));
}
public function generate()
{
$tables = DB::select("SELECT tablename FROM pg_tables WHERE schemaname = 'public'");
$tableNames = array_map(fn($t) => $t->tablename, $tables);
//POSTGRESS
//$tables = DB::select("SELECT tablename FROM pg_tables WHERE schemaname = 'public'");
//$tableNames = array_map(fn($t) => $t->tablename, $tables);
//MYSQL
$tables = DB::select('SHOW TABLES');
$tableNames = array_map('current', $tables);
foreach ($tableNames as $table) {
try {
$data = DB::table($table)->get();
@@ -87,7 +107,11 @@ class JsonTransferController extends Controller
// Kosongkan tabel sebelum import (opsional, hati-hati!)
DB::table($table)->truncate();
DB::table($table)->insert($data);
$chunks = array_chunk($data, 200); // ubah 1000 sesuai kemampuan server
foreach ($chunks as $chunk) {
DB::table($table)->insert($chunk);
}
DB::commit();
return redirect()->back()->with('success', "Data untuk tabel $table berhasil di-import.");