-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmigrate.js
More file actions
27 lines (22 loc) · 736 Bytes
/
Copy pathmigrate.js
File metadata and controls
27 lines (22 loc) · 736 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
import db from './db/db.config.js';
async function runMigration() {
try {
console.log('Connecting to cloud database...');
// Execute your exact schema configuration
await db.query(`
CREATE TABLE IF NOT EXISTS conversations (
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
role ENUM('user', 'assistant') NOT NULL,
content TEXT NOT NULL,
token_count INT UNSIGNED NOT NULL DEFAULT 0,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
)
`);
console.log('🎉 Database table created successfully in the cloud!');
process.exit(0);
} catch (error) {
console.error('❌ Migration failed:', error);
process.exit(1);
}
}
runMigration();