feat: remindme plugin
All checks were successful
ci/woodpecker/tag/release Pipeline was successful

This commit is contained in:
Felipe M 2025-04-22 11:29:39 +02:00
parent 21e4c434fd
commit 72c6dd6982
Signed by: fmartingr
GPG key ID: CCFBC5637D4000A8
12 changed files with 695 additions and 48 deletions

View file

@ -208,4 +208,4 @@ func MigrateDown(db *sql.DB, targetVersion int) error {
}
return nil
}
}

View file

@ -8,6 +8,7 @@ import (
func init() {
// Register migrations
Register(1, "Initial schema with bcrypt passwords", migrateInitialSchemaUp, migrateInitialSchemaDown)
Register(2, "Add reminders table", migrateRemindersUp, migrateRemindersDown)
}
// Initial schema creation with bcrypt passwords - version 1
@ -60,14 +61,14 @@ func migrateInitialSchemaUp(db *sql.DB) error {
if err != nil {
return err
}
// Check if users table is empty before inserting
var count int
err = db.QueryRow("SELECT COUNT(*) FROM users").Scan(&count)
if err != nil {
return err
}
if count == 0 {
_, err = db.Exec(
"INSERT INTO users (username, password) VALUES (?, ?)",
@ -99,4 +100,29 @@ func migrateInitialSchemaDown(db *sql.DB) error {
}
return nil
}
}
// Add reminders table - version 2
func migrateRemindersUp(db *sql.DB) error {
_, err := db.Exec(`
CREATE TABLE IF NOT EXISTS reminders (
id INTEGER PRIMARY KEY AUTOINCREMENT,
platform TEXT NOT NULL,
channel_id TEXT NOT NULL,
message_id TEXT NOT NULL,
reply_to_id TEXT NOT NULL,
user_id TEXT NOT NULL,
username TEXT NOT NULL,
created_at TIMESTAMP NOT NULL,
trigger_at TIMESTAMP NOT NULL,
content TEXT NOT NULL,
processed BOOLEAN NOT NULL DEFAULT 0
)
`)
return err
}
func migrateRemindersDown(db *sql.DB) error {
_, err := db.Exec(`DROP TABLE IF EXISTS reminders`)
return err
}