-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_table_structure.js
More file actions
62 lines (52 loc) · 1.78 KB
/
Copy pathcheck_table_structure.js
File metadata and controls
62 lines (52 loc) · 1.78 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
57
58
59
60
61
62
const db = require('./db1');
async function checkTableStructure() {
try {
console.log('🔍 Checking ilos_applications table structure...');
// Check if table exists
const tableExists = await db.query(`
SELECT EXISTS (
SELECT FROM information_schema.tables
WHERE table_name = 'ilos_applications'
);
`);
if (!tableExists.rows[0].exists) {
console.log('❌ Table ilos_applications does not exist');
return;
}
// Get column information
const columns = await db.query(`
SELECT column_name, data_type, is_nullable, column_default
FROM information_schema.columns
WHERE table_name = 'ilos_applications'
ORDER BY ordinal_position;
`);
console.log('📋 Table structure:');
columns.rows.forEach(col => {
console.log(` - ${col.column_name}: ${col.data_type} (nullable: ${col.is_nullable}, default: ${col.column_default})`);
});
// Check if status column exists
const statusColumn = columns.rows.find(col => col.column_name === 'status');
if (statusColumn) {
console.log('✅ Status column exists');
// Get distinct status values
const statusValues = await db.query(`
SELECT DISTINCT status, COUNT(*) as count
FROM ilos_applications
WHERE status IS NOT NULL
GROUP BY status
ORDER BY status;
`);
console.log('📊 Current status values:');
statusValues.rows.forEach(row => {
console.log(` - ${row.status}: ${row.count} records`);
});
} else {
console.log('❌ Status column does not exist');
}
} catch (error) {
console.error('❌ Error checking table structure:', error.message);
} finally {
process.exit(0);
}
}
checkTableStructure();