summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-05 22:08:33 +0300
committerPaul Buetow <paul@buetow.org>2026-05-05 22:08:33 +0300
commitf96c13de4828a3d531f4dc62f63ba571542c3ece (patch)
treebff84878260815f5304b4b85ccfe6982bec44c55 /internal
parent83ffe8544aa7845810049083d1376f7c7d01cd2c (diff)
Fix podcast migration backward compatibility and login logo width
Diffstat (limited to 'internal')
-rw-r--r--internal/repository/migrate.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/internal/repository/migrate.go b/internal/repository/migrate.go
index 2896906..d64732d 100644
--- a/internal/repository/migrate.go
+++ b/internal/repository/migrate.go
@@ -196,6 +196,21 @@ func enableForeignKeys(db *sql.DB) error {
return nil
}
+// addPodcastColumn ensures the sets table has the is_podcast column.
+// It safely ignores the error if the column already exists.
+func addPodcastColumn(db *sql.DB) error {
+ _, err := db.Exec(`ALTER TABLE sets ADD COLUMN is_podcast INTEGER NOT NULL DEFAULT 0;`)
+ if err != nil {
+ // SQLite returns a generic error message for duplicate columns.
+ if err.Error() == "duplicate column name: is_podcast" ||
+ err.Error() == "SQL logic error: duplicate column name: is_podcast (1)" {
+ return nil
+ }
+ return fmt.Errorf("add is_podcast column: %w", err)
+ }
+ return nil
+}
+
// Migrate creates the database schema if it does not exist.
func Migrate(db *sql.DB) error {
if err := enableForeignKeys(db); err != nil {
@@ -204,6 +219,11 @@ func Migrate(db *sql.DB) error {
if err := execSchema(db, "tables", tablesSchema); err != nil {
return err
}
+ // Backward-compatibility: older databases may have a sets table
+ // without the is_podcast column. Add it before creating the index.
+ if err := addPodcastColumn(db); err != nil {
+ return err
+ }
if err := execSchema(db, "indexes", indexesSchema); err != nil {
return err
}