# Solution to Database Path Issue ## Problem The application was encountering the following errors when starting up: ``` Error running migration add_episode_ordering.py: no such table: podcasts Error running migration add_podcast_tags.py: no such table: podcasts Error running migration add_season_explicit_naming_format.py: no such table: episodes ``` And when accessing podcast pages: ``` sqlite3.OperationalError: no such column: podcasts.tags ``` ## Root Cause The issue was caused by a mismatch between where the application was looking for the database file and where the database file was actually located: 1. The application was configured to look for the database file at `sqlite:///podcastrr.db`, which is a relative path to a file in the root directory. 2. However, the actual database file was located in the `instance` directory (`instance/podcastrr.db`). 3. This caused the migrations to fail because they couldn't find the tables they were trying to modify. ## Solution The solution was to update the database path in the application configuration to point to the correct location: 1. Modified `application.py` to change the default database path from `sqlite:///podcastrr.db` to `sqlite:///instance/podcastrr.db`. 2. This ensures that the application and all migrations look for the database file in the `instance` directory, which is where Flask stores instance-specific files by default. ## Changes Made In `application.py`, the following change was made: ```python # Before SQLALCHEMY_DATABASE_URI=os.environ.get('DATABASE_URI', 'sqlite:///podcastrr.db') # After SQLALCHEMY_DATABASE_URI=os.environ.get('DATABASE_URI', 'sqlite:///instance/podcastrr.db') ``` ## How to Verify the Solution 1. Run the application: ``` python main.py ``` 2. Verify that the application starts without any database-related errors. 3. Access a podcast page to verify that the "no such column: podcasts.tags" error is resolved. ## Preventing Similar Issues in the Future To prevent similar issues in the future: 1. Always use consistent database paths across the application. 2. Consider using Flask's built-in `app.instance_path` to get the correct instance directory path. 3. Update the `.env.example` file to reflect the correct database path: ``` DATABASE_URI=sqlite:///instance/podcastrr.db ``` 4. Document the expected location of the database file in the README.md file.