40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
/**
|
||
* Migration script to add payment_proof field to withdrawal table
|
||
*/
|
||
const { sequelize } = require('./src/config/database');
|
||
|
||
async function addPaymentProofField() {
|
||
try {
|
||
console.log('Connecting to database...');
|
||
await sequelize.authenticate();
|
||
console.log('Database connected.');
|
||
|
||
// Check if column already exists
|
||
const [results] = await sequelize.query(`
|
||
SELECT COLUMN_NAME
|
||
FROM INFORMATION_SCHEMA.COLUMNS
|
||
WHERE TABLE_NAME = 'withdrawal' AND COLUMN_NAME = 'payment_proof'
|
||
`);
|
||
|
||
if (results.length > 0) {
|
||
console.log('Column payment_proof already exists in withdrawal table.');
|
||
process.exit(0);
|
||
}
|
||
|
||
// Add the column
|
||
console.log('Adding payment_proof column to withdrawal table...');
|
||
await sequelize.query(`
|
||
ALTER TABLE withdrawal
|
||
ADD COLUMN payment_proof VARCHAR(500) NULL COMMENT '支付凭证图片URL(管理员批准时上传)'
|
||
`);
|
||
|
||
console.log('Successfully added payment_proof column to withdrawal table.');
|
||
process.exit(0);
|
||
} catch (error) {
|
||
console.error('Migration failed:', error);
|
||
process.exit(1);
|
||
}
|
||
}
|
||
|
||
addPaymentProofField();
|