123456789101112131415161718192021222324 |
- -- 修改群组表,添加新字段
- ALTER TABLE groups
- ADD COLUMN fee_rate DECIMAL(5,2) DEFAULT 0.00 COMMENT '费率' AFTER group_name,
- ADD COLUMN exchange_rate DECIMAL(10,4) DEFAULT 1.0000 COMMENT '汇率' AFTER fee_rate,
- ADD COLUMN creator_id INT NOT NULL COMMENT '创建人ID' AFTER exchange_rate,
- ADD COLUMN admin_id INT NOT NULL COMMENT '管理员ID' AFTER creator_id,
- ADD CONSTRAINT fk_groups_creator FOREIGN KEY (creator_id) REFERENCES users(id),
- ADD CONSTRAINT fk_groups_admin FOREIGN KEY (admin_id) REFERENCES users(id);
- -- 创建入款出款记录表
- CREATE TABLE IF NOT EXISTS money_records (
- id INT AUTO_INCREMENT PRIMARY KEY,
- time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- amount DECIMAL(10,2) NOT NULL COMMENT '金额',
- operator_id INT NOT NULL COMMENT '操作人ID',
- responder_id INT NOT NULL COMMENT '回复人ID',
- group_id VARCHAR(50) NOT NULL COMMENT '关联群组ID',
- type ENUM('deposit', 'withdrawal') NOT NULL COMMENT '类型:入款/出款',
- status ENUM('pending', 'approved', 'rejected') DEFAULT 'pending' COMMENT '状态',
- FOREIGN KEY (operator_id) REFERENCES users(id),
- FOREIGN KEY (responder_id) REFERENCES users(id),
- FOREIGN KEY (group_id) REFERENCES groups(group_id),
- INDEX idx_group_time (group_id, time)
- );
|