appointment_system/backend/add-withdrawal-payment-proof-field.js
2026-01-24 00:28:20 +08:00

40 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 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();