First commit

This commit is contained in:
Randa Firman Putra
2025-06-18 22:03:32 +07:00
parent 852121be46
commit e028039ee2
123 changed files with 17506 additions and 144 deletions

40
setup_database.js Normal file
View File

@@ -0,0 +1,40 @@
const mysql = require('mysql2/promise');
const fs = require('fs');
const path = require('path');
async function setupDatabase() {
let connection;
try {
// Create connection without database
connection = await mysql.createConnection({
host: '127.0.0.1',
port: 3306,
user: 'root',
password: 'semogabisayok321'
});
console.log('Connected to MySQL server');
// Read and execute check_table.sql
const checkTableSql = fs.readFileSync(path.join(__dirname, 'check_table.sql'), 'utf8');
const statements = checkTableSql.split(';').filter(stmt => stmt.trim());
for (const statement of statements) {
if (statement.trim()) {
console.log('Executing:', statement.substring(0, 50) + '...');
await connection.query(statement);
}
}
console.log('Database setup completed successfully');
} catch (error) {
console.error('Error setting up database:', error);
} finally {
if (connection) {
await connection.end();
console.log('Database connection closed');
}
}
}
setupDatabase();