Updates
This commit is contained in:
parent
e86ab53de5
commit
095bf52a2f
29 changed files with 2494 additions and 758 deletions
3
migrations/__init__.py
Normal file
3
migrations/__init__.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
"""
|
||||
Migrations package for Podcastrr.
|
||||
"""
|
33
migrations/add_episode_ordering.py
Normal file
33
migrations/add_episode_ordering.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
"""
|
||||
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
|
47
migrations/add_season_explicit_naming_format.py
Normal file
47
migrations/add_season_explicit_naming_format.py
Normal file
|
@ -0,0 +1,47 @@
|
|||
"""
|
||||
Migration script to add season, explicit, and naming_format fields to the database.
|
||||
"""
|
||||
import sqlite3
|
||||
import os
|
||||
from flask import current_app
|
||||
|
||||
def run_migration():
|
||||
"""
|
||||
Run the migration to add the new fields to the database.
|
||||
"""
|
||||
# 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 columns already exist in the episodes table
|
||||
cursor.execute("PRAGMA table_info(episodes)")
|
||||
columns = [column[1] for column in cursor.fetchall()]
|
||||
|
||||
# Add the season column if it doesn't exist
|
||||
if 'season' not in columns:
|
||||
print("Adding 'season' column to episodes table...")
|
||||
cursor.execute("ALTER TABLE episodes ADD COLUMN season INTEGER")
|
||||
|
||||
# Add the explicit column if it doesn't exist
|
||||
if 'explicit' not in columns:
|
||||
print("Adding 'explicit' column to episodes table...")
|
||||
cursor.execute("ALTER TABLE episodes ADD COLUMN explicit BOOLEAN")
|
||||
|
||||
# Check if the naming_format column already exists in the podcasts table
|
||||
cursor.execute("PRAGMA table_info(podcasts)")
|
||||
columns = [column[1] for column in cursor.fetchall()]
|
||||
|
||||
# Add the naming_format column if it doesn't exist
|
||||
if 'naming_format' not in columns:
|
||||
print("Adding 'naming_format' column to podcasts table...")
|
||||
cursor.execute("ALTER TABLE podcasts ADD COLUMN naming_format TEXT")
|
||||
|
||||
# Commit the changes and close the connection
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
print("Migration completed successfully!")
|
||||
return True
|
Loading…
Add table
Add a link
Reference in a new issue