Compare commits

...

2 Commits

Author SHA1 Message Date
Araya's Project 830b127478 New config for docker-compose 2026-06-10 23:51:31 +07:00
Araya's Project a7b5af2de8 New config for docker-compose 2026-06-10 23:49:15 +07:00
2 changed files with 45 additions and 1 deletions
+44
View File
@@ -0,0 +1,44 @@
<?php
// FILE INI HANYA UNTUK INISIALISASI DATABASE
// HAPUS SETELAH DIPAKAI!
$host = getenv('DB_HOST') ?: 'localhost';
$user = getenv('DB_USER') ?: 'root';
$pass = getenv('DB_PASS') ?: '';
$conn = new mysqli($host, $user, $pass);
if ($conn->connect_error) {
die("<b style='color:red'>Koneksi gagal: " . $conn->connect_error . "</b>");
}
$sqls = file_get_contents(__DIR__ . '/database/init.sql');
// Pisah per statement
$statements = array_filter(array_map('trim', explode(';', $sqls)));
$success = 0;
$errors = [];
foreach ($statements as $sql) {
if (empty($sql)) continue;
if ($conn->query($sql) === TRUE) {
$success++;
} else {
$errors[] = htmlspecialchars($sql) . "<br><b style='color:red'>" . $conn->error . "</b>";
}
}
echo "<h2>DB Init Result</h2>";
echo "<p style='color:green'>✅ $success statements executed successfully.</p>";
if (!empty($errors)) {
echo "<h3 style='color:red'>Errors (" . count($errors) . "):</h3>";
foreach ($errors as $e) {
echo "<pre style='background:#fee;padding:8px'>$e</pre>";
}
} else {
echo "<p style='color:green'>✅ All done! Semua database berhasil dibuat.</p>";
echo "<p style='color:red'><b>⚠️ HAPUS FILE INI SEKARANG dari repo!</b></p>";
}
$conn->close();
+1 -1
View File
@@ -14,7 +14,7 @@ services:
image: mysql:8.0
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: rootpassword
MYSQL_ROOT_PASSWORD: Cb6aGo2ccTVo10wdtU3QM0Ch2yEE8Z1PR9OIXUvmKfAQrCmntWabaQa3JFqi0Vz0
MYSQL_DATABASE: sig_spbu
volumes:
- db_data:/var/lib/mysql