-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrop_tables.mjs
More file actions
49 lines (41 loc) · 1014 Bytes
/
drop_tables.mjs
File metadata and controls
49 lines (41 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import mysql from 'mysql2/promise';
import * as dotenv from 'dotenv';
dotenv.config();
const url = process.env.DATABASE_URL;
const match = url.match(/mysql:\/\/([^:]+):([^@]+)@([^:]+):(\d+)\/([^?]+)/);
if (!match) {
console.error('Invalid DATABASE_URL');
process.exit(1);
}
const [, user, password, host, port, database] = match;
const connection = await mysql.createConnection({
host,
port: parseInt(port),
user,
password,
database,
});
const tables = [
'llm_providers',
'integration_modules',
'system_alerts',
'agent_metrics',
'workflow_templates',
'orchestration_configs',
'execution_logs',
'agent_messages',
'tasks',
'workflows',
'agents',
'users',
];
for (const table of tables) {
try {
await connection.execute(`DROP TABLE IF EXISTS ${table}`);
console.log(`✓ Dropped ${table}`);
} catch (error) {
console.error(`✗ Error dropping ${table}:`, error.message);
}
}
await connection.end();
console.log('\n✓ All tables dropped successfully');