Merge branch 'libretime:main' into master-me-processing

This commit is contained in:
Thomas Göttgens 2024-12-21 21:16:38 +01:00 committed by GitHub
commit 59ba09bd2c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 24 additions and 7 deletions

View File

@ -8,8 +8,6 @@ UP = """
-- DELETE FROM cc_pref WHERE keystr = 'system_version';
-- INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '2.5.5');
ALTER TABLE cc_show ADD COLUMN image_path varchar(255) DEFAULT '';
ALTER TABLE cc_show_instances ADD COLUMN description varchar(255) DEFAULT '';
"""
DOWN = None

View File

@ -5,7 +5,7 @@ from django.db import migrations
from ._migrations import legacy_migration_factory
UP = """
ALTER TABLE cc_files ADD COLUMN artwork TYPE character varying(255);
ALTER TABLE cc_files ADD COLUMN artwork VARCHAR(255);
"""
DOWN = None

View File

@ -4,12 +4,18 @@ from django.db import migrations
from ._migrations import legacy_migration_factory
# This migration is currently a placeholder for 3.0.0-alpha.9.1.
# Please do not remove it. There are currently no actions, but it
# needs to remain intact so it does not fail when called from the
# migrations script. Any future migrations that may apply to
# 3.0.0-alpha.9.1 will be added to this file.
UP = """
ALTER TABLE cc_files ADD COLUMN artwork VARCHAR(4096);
"""
DOWN = """
ALTER TABLE cc_files DROP COLUMN IF EXISTS artwork;
"""

View File

@ -11,15 +11,28 @@ def get_schema_version():
Don't use django models as they might break in the future. Our concern is to upgrade
the legacy database schema to the point where django is in charge of the migrations.
An airtime 2.5.1 migration will not have schema_version, in that case, we look for
system_version to have a value of 2.5.1 and return that as the schema version value
(really just needs to be anything besides None, so that the next migration doesn't overwrite
the database)
"""
if "cc_pref" not in connection.introspection.table_names():
return None
with connection.cursor() as cursor:
cursor.execute("SELECT valstr FROM cc_pref WHERE keystr = 'schema_version'")
cursor.execute(
"""
SELECT valstr AS version
FROM cc_pref
WHERE (keystr = 'schema_version') OR (keystr = 'system_version' AND valstr = '2.5.1')
"""
)
row = cursor.fetchone()
return row[0] if row else None
if row and row[0]:
return row[0]
return None
def set_schema_version(cursor, version: str):