fix: db migration tab char corrupted, restore historical trades
This commit is contained in:
@@ -113,6 +113,18 @@ func (d *DB) migrate() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Migration v2: add per-exchange fee/pnl columns (idempotent)
|
||||
for _, col := range []string{"pnl_long_usd", "pnl_short_usd", "fee_long_usd", "fee_short_usd"} {
|
||||
var found int
|
||||
d.QueryRow("SELECT COUNT(*) FROM pragma_table_info('trades') WHERE name=?", col).Scan(&found)
|
||||
if found == 0 {
|
||||
if _, err := d.Exec("ALTER TABLE trades ADD COLUMN " + col + " REAL"); err != nil {
|
||||
log.Printf("[DB] Migration: add column %s: %v", col, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf("[DB] SQLite ready: %s", d.Path)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user