33 lines
No EOL
1.1 KiB
Python
33 lines
No EOL
1.1 KiB
Python
"""
|
|
Migration script to add episode_ordering field to the podcasts table.
|
|
"""
|
|
import sqlite3
|
|
import os
|
|
from flask import current_app
|
|
|
|
def run_migration():
|
|
"""
|
|
Run the migration to add the episode_ordering field to the podcasts table.
|
|
"""
|
|
# Get the database path from the app config
|
|
db_path = current_app.config['SQLALCHEMY_DATABASE_URI'].replace('sqlite:///', '')
|
|
|
|
# Connect to the database
|
|
conn = sqlite3.connect(db_path)
|
|
cursor = conn.cursor()
|
|
|
|
# Check if the episode_ordering column already exists in the podcasts table
|
|
cursor.execute("PRAGMA table_info(podcasts)")
|
|
columns = [column[1] for column in cursor.fetchall()]
|
|
|
|
# Add the episode_ordering column if it doesn't exist
|
|
if 'episode_ordering' not in columns:
|
|
print("Adding 'episode_ordering' column to podcasts table...")
|
|
cursor.execute("ALTER TABLE podcasts ADD COLUMN episode_ordering TEXT DEFAULT 'absolute'")
|
|
|
|
# Commit the changes and close the connection
|
|
conn.commit()
|
|
conn.close()
|
|
|
|
print("Episode ordering migration completed successfully!")
|
|
return True |