完成品
This commit is contained in:
34
scripts/clear-database.js
Normal file
34
scripts/clear-database.js
Normal file
@@ -0,0 +1,34 @@
|
||||
const mysql = require('mysql2/promise');
|
||||
|
||||
async function clearDatabase() {
|
||||
const connection = await mysql.createConnection({
|
||||
host: 'mysql.theaken.com',
|
||||
port: 33306,
|
||||
user: 'AI_Platform',
|
||||
password: 'Aa123456',
|
||||
database: 'db_AI_Platform'
|
||||
});
|
||||
|
||||
console.log('🗑️ 清空資料庫...');
|
||||
|
||||
// 清空所有表(按依賴順序)
|
||||
const tables = [
|
||||
'app_judge_scores',
|
||||
'competition_apps',
|
||||
'competition_judges',
|
||||
'apps',
|
||||
'judges',
|
||||
'competitions',
|
||||
'users'
|
||||
];
|
||||
|
||||
for (const table of tables) {
|
||||
await connection.execute(`DELETE FROM ${table}`);
|
||||
console.log(`✅ 清空了 ${table} 表`);
|
||||
}
|
||||
|
||||
await connection.end();
|
||||
console.log('🎉 資料庫清空完成!');
|
||||
}
|
||||
|
||||
clearDatabase().catch(console.error);
|
Reference in New Issue
Block a user