/** * Migration script to add payment_proof field to payment_orders 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 = 'payment_orders' AND COLUMN_NAME = 'payment_proof' `); if (results.length > 0) { console.log('Column payment_proof already exists in payment_orders table.'); process.exit(0); } // Add the column console.log('Adding payment_proof column to payment_orders table...'); await sequelize.query(` ALTER TABLE payment_orders ADD COLUMN payment_proof VARCHAR(500) NULL COMMENT '支付凭证图片URL' `); console.log('Successfully added payment_proof column to payment_orders table.'); process.exit(0); } catch (error) { console.error('Migration failed:', error); process.exit(1); } } addPaymentProofField();