-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-communication-migration.js
More file actions
56 lines (46 loc) · 2.14 KB
/
run-communication-migration.js
File metadata and controls
56 lines (46 loc) · 2.14 KB
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
50
51
52
53
54
55
56
const { sequelize } = require('./src/models');
async function runMigration() {
try {
console.log('Running communications table migration...');
// Check if table already exists
const tableExists = await sequelize.getQueryInterface().showAllTables()
.then(tables => tables.includes('communications'));
if (tableExists) {
console.log('✅ Communications table already exists!');
console.log('The communications system is ready to use.');
console.log('Features available:');
console.log(' - Feedback submissions');
console.log(' - Chat messages with replies');
console.log(' - Notifications (scheduled and instant)');
console.log(' - Push notifications');
console.log(' - Multi-language support');
console.log(' - Priority levels and status tracking');
return;
}
// Import and run the migration
const migration = require('./src/migrations/20240324000000-create-communications-table.js');
// Get the queryInterface from sequelize
const queryInterface = sequelize.getQueryInterface();
// Run the migration
await migration.up(queryInterface, sequelize.Sequelize);
console.log('✅ Communications table migration completed successfully!');
console.log('The communications table has been created with all necessary fields and indexes.');
console.log('This includes support for:');
console.log(' - Feedback submissions');
console.log(' - Chat messages with replies');
console.log(' - Notifications (scheduled and instant)');
console.log(' - Push notifications');
console.log(' - Multi-language support');
console.log(' - Priority levels and status tracking');
} catch (error) {
console.error('❌ Migration failed:', error);
// If it's a duplicate key error, the table might already exist
if (error.original && error.original.code === 'ER_DUP_KEYNAME') {
console.log('⚠️ Table exists but indexes may be missing. The system should still work.');
console.log('You can test the API endpoints now.');
}
} finally {
await sequelize.close();
}
}
runMigration();