feat: add Telegram bot with notifications and scheduler
This commit is contained in:
@@ -32,7 +32,7 @@ func RunMigrations(db *sqlx.DB) error {
|
||||
id SERIAL PRIMARY KEY,
|
||||
user_id INTEGER REFERENCES users(id) ON DELETE CASCADE,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
description TEXT DEFAULT '''',
|
||||
description TEXT DEFAULT '',
|
||||
color VARCHAR(20) DEFAULT '#6366f1',
|
||||
icon VARCHAR(50) DEFAULT 'check',
|
||||
frequency VARCHAR(20) DEFAULT 'daily',
|
||||
@@ -48,7 +48,7 @@ func RunMigrations(db *sqlx.DB) error {
|
||||
user_id INTEGER REFERENCES users(id) ON DELETE CASCADE,
|
||||
date DATE NOT NULL,
|
||||
count INTEGER DEFAULT 1,
|
||||
note TEXT DEFAULT '''',
|
||||
note TEXT DEFAULT '',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE(habit_id, date)
|
||||
)`,
|
||||
@@ -65,7 +65,7 @@ func RunMigrations(db *sqlx.DB) error {
|
||||
id SERIAL PRIMARY KEY,
|
||||
user_id INTEGER REFERENCES users(id) ON DELETE CASCADE,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
description TEXT DEFAULT '''',
|
||||
description TEXT DEFAULT '',
|
||||
icon VARCHAR(10) DEFAULT '📋',
|
||||
color VARCHAR(7) DEFAULT '#6B7280',
|
||||
due_date DATE,
|
||||
@@ -83,13 +83,18 @@ func RunMigrations(db *sqlx.DB) error {
|
||||
`CREATE INDEX IF NOT EXISTS idx_tasks_user_id ON tasks(user_id)`,
|
||||
`CREATE INDEX IF NOT EXISTS idx_tasks_due_date ON tasks(due_date)`,
|
||||
`CREATE INDEX IF NOT EXISTS idx_tasks_completed ON tasks(user_id, completed_at)`,
|
||||
// Migration: add email_verified column if not exists
|
||||
`DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name='users' AND column_name='email_verified') THEN
|
||||
ALTER TABLE users ADD COLUMN email_verified BOOLEAN DEFAULT FALSE;
|
||||
END IF;
|
||||
END $$;`,
|
||||
`ALTER TABLE users ADD COLUMN IF NOT EXISTS telegram_chat_id BIGINT`,
|
||||
`ALTER TABLE users ADD COLUMN IF NOT EXISTS notifications_enabled BOOLEAN DEFAULT true`,
|
||||
`ALTER TABLE users ADD COLUMN IF NOT EXISTS timezone VARCHAR(50) DEFAULT 'Europe/Moscow'`,
|
||||
`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)`,
|
||||
}
|
||||
|
||||
for _, migration := range migrations {
|
||||
|
||||
Reference in New Issue
Block a user