feat(savings): Add savings module with categories, transactions, recurring plans
- Categories: regular, deposits, credits, recurring, multi-user, accounts - Transactions: deposits and withdrawals with user tracking - Recurring plans: monthly payment obligations per user - Stats: overdues calculation with allocation algorithm - Excludes is_account categories from total sums - Documentation: docs/SAVINGS.md
This commit is contained in:
@@ -95,6 +95,28 @@ func RunMigrations(db *sqlx.DB) error {
|
||||
`ALTER TABLE tasks ADD COLUMN IF NOT EXISTS reminder_time TIME`,
|
||||
`ALTER TABLE habits ADD COLUMN IF NOT EXISTS reminder_time TIME`,
|
||||
`CREATE INDEX IF NOT EXISTS idx_users_telegram_chat_id ON users(telegram_chat_id)`,
|
||||
// Recurring tasks support
|
||||
`ALTER TABLE tasks ADD COLUMN IF NOT EXISTS is_recurring BOOLEAN DEFAULT false`,
|
||||
`ALTER TABLE tasks ADD COLUMN IF NOT EXISTS recurrence_type VARCHAR(20)`,
|
||||
`ALTER TABLE tasks ADD COLUMN IF NOT EXISTS recurrence_interval INTEGER DEFAULT 1`,
|
||||
`ALTER TABLE tasks ADD COLUMN IF NOT EXISTS recurrence_end_date DATE`,
|
||||
`ALTER TABLE tasks ADD COLUMN IF NOT EXISTS parent_task_id INTEGER REFERENCES tasks(id) ON DELETE SET NULL`,
|
||||
`CREATE INDEX IF NOT EXISTS idx_tasks_parent_id ON tasks(parent_task_id)`,
|
||||
`CREATE INDEX IF NOT EXISTS idx_tasks_recurring ON tasks(is_recurring) WHERE is_recurring = true`,
|
||||
// Habit freezes support
|
||||
`CREATE TABLE IF NOT EXISTS habit_freezes (
|
||||
id SERIAL PRIMARY KEY,
|
||||
habit_id INTEGER REFERENCES habits(id) ON DELETE CASCADE,
|
||||
user_id INTEGER REFERENCES users(id) ON DELETE CASCADE,
|
||||
start_date DATE NOT NULL,
|
||||
end_date DATE NOT NULL,
|
||||
reason VARCHAR(255) DEFAULT '',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
)`,
|
||||
`CREATE INDEX IF NOT EXISTS idx_habit_freezes_habit ON habit_freezes(habit_id)`,
|
||||
`CREATE INDEX IF NOT EXISTS idx_habit_freezes_dates ON habit_freezes(start_date, end_date)`,
|
||||
// Habit start_date support
|
||||
`ALTER TABLE habits ADD COLUMN IF NOT EXISTS start_date DATE`,
|
||||
}
|
||||
|
||||
for _, migration := range migrations {
|
||||
|
||||
Reference in New Issue
Block a user