feat: 初始化核心数据库表结构、Go模型并包含日期字段类型迁移脚本

This commit is contained in:
2026-01-28 23:30:54 +08:00
parent d588235461
commit aad9fec461
3 changed files with 21 additions and 5 deletions

View File

@@ -0,0 +1,17 @@
-- Migration: Change transaction_date from DATE to DATETIME
-- This migration updates the transaction_date column to store both date and time.
-- Run this SQL on your MySQL database.
-- Step 1: Modify the column type (preserves existing data - dates will have 00:00:00 time)
ALTER TABLE `transactions` MODIFY COLUMN `transaction_date` DATETIME NOT NULL;
-- Step 2 (Optional): Migrate existing transaction_time data into transaction_date
-- This updates existing records to combine date + time into the transaction_date column
-- Only run this if you have existing data that you want to preserve time info for
UPDATE `transactions`
SET `transaction_date` = TIMESTAMP(DATE(`transaction_date`), IFNULL(`transaction_time`, '00:00:00'))
WHERE `transaction_time` IS NOT NULL;
-- Note: After running this migration, the transaction_time column is no longer used
-- but is kept for backward compatibility. New transactions will store full datetime
-- in the transaction_date column.