From 2e6c5c31171ea100a3a1b4d45b33e724f9c31b66 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 1 Oct 2025 15:53:14 +0200 Subject: [PATCH] Fix schema.sql conflicts with migrations on fresh DB install When running the API on a clean database instance, migrations were failing with errors: 1. Duplicate column 'publishOn': Error: Duplicate column name 'publishOn' at PromisePool.query sql: 'ALTER TABLE anchorPodcastEpisodes ADD COLUMN publishOn DATETIME DEFAULT NULL AFTER created' 2. Missing table 'hosterPodcastMetrics': Error: Table 'openpodcast.hosterPodcastMetrics' doesn't exist sql: 'ALTER TABLE hosterPodcastMetrics MODIFY dimension ENUM(...)' Root cause: schema.sql contained changes that were supposed to be applied via migrations (migration 6 for publishOn, migration 17 for hoster enum values). When migrations ran after schema.sql on a fresh DB, they tried to add/modify things that already existed. Fix: Remove migration changes from schema.sql so it reflects the base state before migrations run. Migrations then apply changes incrementally: - Removed 'publishOn' column (added by migration 6) - Removed 'listeners' and 'subscribers' from hosterPodcastMetrics enum (added by migration 17) This ensures schema.sql and migrations don't conflict on fresh installs. --- db_schema/schema.sql | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/db_schema/schema.sql b/db_schema/schema.sql index 3b67d42..e23d667 100644 --- a/db_schema/schema.sql +++ b/db_schema/schema.sql @@ -703,7 +703,6 @@ CREATE TABLE IF NOT EXISTS anchorPodcastEpisodes ( share_link_embed_path VARCHAR(512) NOT NULL, ad_count INTEGER NOT NULL, created DATETIME NOT NULL, - publishOn DATETIME, duration BIGINT NOT NULL, hour_offset INTEGER NOT NULL, is_deleted BOOLEAN NOT NULL, @@ -761,9 +760,7 @@ CREATE TABLE IF NOT EXISTS hosterPodcastMetrics ( 'downloads', 'platforms', 'clients', - 'sources', - 'listeners', - 'subscribers' + 'sources' ) NOT NULL, subdimension SMALLINT UNSIGNED NOT NULL, value INTEGER NOT NULL,