From b7b825f0efe113532bf11490c60590a0fea1b075 Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Sat, 14 Dec 2024 11:58:54 +0000 Subject: [PATCH] Restart Alembic migations Alembic was generating empty migraiton files. Restart Alembic from scracth which resolved problem. --- migrations/script.py.mako | 31 ++++- ...e_add_sort_column_deleted_and_query_to_.py | 32 ----- ...90f8_add_played_column_to_playlist_rows.py | 32 ----- ...1bc727e5e87f_add_columns_to_track_table.py | 40 ------- ...fee96_add_constraint_to_playlist_tracks.py | 34 ------ ...9a002f989d_fixup_playdates_relationship.py | 34 ------ ...1_drop_uniquerow_index_on_playlist_rows.py | 24 ---- .../2caa3d37f211_add_tracks_intro_column.py | 110 ------------------ ...37d3cf07f_add_playlist_dates_and_loaded.py | 30 ----- ...ab_migrate_sqla_2_and_remove_redundant_.py | 72 ------------ ...063011ed67_schema_changes_for_row_notes.py | 54 --------- ...rename_playlist_tracks_to_playlist_rows.py | 26 ----- ...4f_record_tab_number_for_open_playlists.py | 32 ----- ...56f_increase_settings_name_len_and_add_.py | 34 ------ .../52cbded98e7c_update_notecolours_table.py | 30 ----- migrations/versions/52d82712d218_initial.py | 24 ---- ...bb2c572e1e5_add_open_field_to_playlists.py | 60 ---------- migrations/versions/6730f03317df_add_carts.py | 41 ------- .../708a21f5c271_initial_migration.py | 75 ++++++++++++ ...5f_add_id_to_playlist_association_table.py | 34 ------ .../a5aada49f2fc_add_notecolours_table.py | 36 ------ .../b0983648595e_add_settings_table.py | 37 ------ .../versions/b4f524e2140c_add_templates.py | 32 ----- ...c55992d1fe5f_add_order_to_colours_table.py | 32 ----- .../e3b04db5506f_add_structure_for_notes.py | 51 -------- ...326c38_add_column_for_bitrate_in_tracks.py | 28 ----- ..._add_sort_to_playlist_association_table.py | 28 ----- ...f07b96a5e60f_add_playlist_and_playtimes.py | 63 ---------- ...b3332_don_t_allow_duplicate_track_paths.py | 28 ----- 29 files changed, 101 insertions(+), 1083 deletions(-) delete mode 100644 migrations/versions/07dcbe6c4f0e_add_sort_column_deleted_and_query_to_.py delete mode 100644 migrations/versions/0c604bf490f8_add_played_column_to_playlist_rows.py delete mode 100644 migrations/versions/1bc727e5e87f_add_columns_to_track_table.py delete mode 100644 migrations/versions/1c4048efee96_add_constraint_to_playlist_tracks.py delete mode 100644 migrations/versions/269a002f989d_fixup_playdates_relationship.py delete mode 100644 migrations/versions/29c0d7ffc741_drop_uniquerow_index_on_playlist_rows.py delete mode 100644 migrations/versions/2caa3d37f211_add_tracks_intro_column.py delete mode 100644 migrations/versions/2cc37d3cf07f_add_playlist_dates_and_loaded.py delete mode 100644 migrations/versions/3a53a9fb26ab_migrate_sqla_2_and_remove_redundant_.py delete mode 100644 migrations/versions/3b063011ed67_schema_changes_for_row_notes.py delete mode 100644 migrations/versions/3f55ac7d80ad_rename_playlist_tracks_to_playlist_rows.py delete mode 100644 migrations/versions/4a7b4ab3354f_record_tab_number_for_open_playlists.py delete mode 100644 migrations/versions/51f61433256f_increase_settings_name_len_and_add_.py delete mode 100644 migrations/versions/52cbded98e7c_update_notecolours_table.py delete mode 100644 migrations/versions/52d82712d218_initial.py delete mode 100644 migrations/versions/5bb2c572e1e5_add_open_field_to_playlists.py delete mode 100644 migrations/versions/6730f03317df_add_carts.py create mode 100644 migrations/versions/708a21f5c271_initial_migration.py delete mode 100644 migrations/versions/9bf80ba3635f_add_id_to_playlist_association_table.py delete mode 100644 migrations/versions/a5aada49f2fc_add_notecolours_table.py delete mode 100644 migrations/versions/b0983648595e_add_settings_table.py delete mode 100644 migrations/versions/b4f524e2140c_add_templates.py delete mode 100644 migrations/versions/c55992d1fe5f_add_order_to_colours_table.py delete mode 100644 migrations/versions/e3b04db5506f_add_structure_for_notes.py delete mode 100644 migrations/versions/ed3100326c38_add_column_for_bitrate_in_tracks.py delete mode 100644 migrations/versions/f071129cbd93_add_sort_to_playlist_association_table.py delete mode 100644 migrations/versions/f07b96a5e60f_add_playlist_and_playtimes.py delete mode 100644 migrations/versions/fe2e127b3332_don_t_allow_duplicate_track_paths.py diff --git a/migrations/script.py.mako b/migrations/script.py.mako index 2c01563..946ab6a 100644 --- a/migrations/script.py.mako +++ b/migrations/script.py.mako @@ -1,4 +1,7 @@ -"""${message} +<%! +import re + +%>"""${message} Revision ID: ${up_revision} Revises: ${down_revision | comma,n} @@ -16,9 +19,27 @@ branch_labels = ${repr(branch_labels)} depends_on = ${repr(depends_on)} -def upgrade(): - ${upgrades if upgrades else "pass"} +def upgrade(engine_name: str) -> None: + globals()["upgrade_%s" % engine_name]() -def downgrade(): - ${downgrades if downgrades else "pass"} +def downgrade(engine_name: str) -> None: + globals()["downgrade_%s" % engine_name]() + +<% + db_names = config.get_main_option("databases") +%> + +## generate an "upgrade_() / downgrade_()" function +## for each database name in the ini file. + +% for db_name in re.split(r',\s*', db_names): + +def upgrade_${db_name}() -> None: + ${context.get("%s_upgrades" % db_name, "pass")} + + +def downgrade_${db_name}() -> None: + ${context.get("%s_downgrades" % db_name, "pass")} + +% endfor diff --git a/migrations/versions/07dcbe6c4f0e_add_sort_column_deleted_and_query_to_.py b/migrations/versions/07dcbe6c4f0e_add_sort_column_deleted_and_query_to_.py deleted file mode 100644 index 8abb6f9..0000000 --- a/migrations/versions/07dcbe6c4f0e_add_sort_column_deleted_and_query_to_.py +++ /dev/null @@ -1,32 +0,0 @@ -"""Add sort_column, deleted and query to playlists table - -Revision ID: 07dcbe6c4f0e -Revises: 4a7b4ab3354f -Create Date: 2022-12-25 10:26:38.200941 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '07dcbe6c4f0e' -down_revision = '4a7b4ab3354f' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('playlists', sa.Column('sort_column', sa.Integer(), nullable=True)) - op.add_column('playlists', sa.Column('query', sa.String(length=256), nullable=True)) - op.add_column('playlists', sa.Column('deleted', sa.Boolean(), nullable=False)) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('playlists', 'deleted') - op.drop_column('playlists', 'query') - op.drop_column('playlists', 'sort_column') - # ### end Alembic commands ### diff --git a/migrations/versions/0c604bf490f8_add_played_column_to_playlist_rows.py b/migrations/versions/0c604bf490f8_add_played_column_to_playlist_rows.py deleted file mode 100644 index 975ce92..0000000 --- a/migrations/versions/0c604bf490f8_add_played_column_to_playlist_rows.py +++ /dev/null @@ -1,32 +0,0 @@ -"""Add 'played' column to playlist_rows - -Revision ID: 0c604bf490f8 -Revises: 29c0d7ffc741 -Create Date: 2022-08-12 14:12:38.419845 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import mysql - -# revision identifiers, used by Alembic. -revision = "0c604bf490f8" -down_revision = "29c0d7ffc741" -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column("playlist_rows", sa.Column("played", sa.Boolean(), nullable=False)) - op.drop_index("ix_tracks_lastplayed", table_name="tracks") - op.drop_column("tracks", "lastplayed") - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column("tracks", sa.Column("lastplayed", mysql.DATETIME(), nullable=True)) - op.create_index("ix_tracks_lastplayed", "tracks", ["lastplayed"], unique=False) - op.drop_column("playlist_rows", "played") - # ### end Alembic commands ### diff --git a/migrations/versions/1bc727e5e87f_add_columns_to_track_table.py b/migrations/versions/1bc727e5e87f_add_columns_to_track_table.py deleted file mode 100644 index bd7f39d..0000000 --- a/migrations/versions/1bc727e5e87f_add_columns_to_track_table.py +++ /dev/null @@ -1,40 +0,0 @@ -"""Add columns to track table - -Revision ID: 1bc727e5e87f -Revises: 52d82712d218 -Create Date: 2021-03-22 22:43:40.458197 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import mysql - -# revision identifiers, used by Alembic. -revision = '1bc727e5e87f' -down_revision = '52d82712d218' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('tracks', sa.Column('duration', sa.Integer(), nullable=True)) - op.add_column('tracks', sa.Column('fade_at', sa.Integer(), nullable=True)) - op.add_column('tracks', sa.Column('silence_at', sa.Integer(), nullable=True)) - op.add_column('tracks', sa.Column('start_gap', sa.Integer(), nullable=True)) - op.drop_index('ix_tracks_length', table_name='tracks') - op.create_index(op.f('ix_tracks_duration'), 'tracks', ['duration'], unique=False) - op.drop_column('tracks', 'length') - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('tracks', sa.Column('length', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True)) - op.drop_index(op.f('ix_tracks_duration'), table_name='tracks') - op.create_index('ix_tracks_length', 'tracks', ['length'], unique=False) - op.drop_column('tracks', 'start_gap') - op.drop_column('tracks', 'silence_at') - op.drop_column('tracks', 'fade_at') - op.drop_column('tracks', 'duration') - # ### end Alembic commands ### diff --git a/migrations/versions/1c4048efee96_add_constraint_to_playlist_tracks.py b/migrations/versions/1c4048efee96_add_constraint_to_playlist_tracks.py deleted file mode 100644 index e8b7403..0000000 --- a/migrations/versions/1c4048efee96_add_constraint_to_playlist_tracks.py +++ /dev/null @@ -1,34 +0,0 @@ -"""Add constraint to playlist_tracks - -Revision ID: 1c4048efee96 -Revises: 52cbded98e7c -Create Date: 2022-03-29 19:26:27.378185 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import mysql - -# revision identifiers, used by Alembic. -revision = '1c4048efee96' -down_revision = '52cbded98e7c' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_unique_constraint('uniquerow', 'playlist_tracks', ['row', 'playlist_id']) - op.alter_column('playlists', 'loaded', - existing_type=mysql.TINYINT(display_width=1), - nullable=False) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('playlists', 'loaded', - existing_type=mysql.TINYINT(display_width=1), - nullable=True) - op.drop_constraint('uniquerow', 'playlist_tracks', type_='unique') - # ### end Alembic commands ### diff --git a/migrations/versions/269a002f989d_fixup_playdates_relationship.py b/migrations/versions/269a002f989d_fixup_playdates_relationship.py deleted file mode 100644 index 6f0f0fc..0000000 --- a/migrations/versions/269a002f989d_fixup_playdates_relationship.py +++ /dev/null @@ -1,34 +0,0 @@ -"""Fixup playdates relationship - -Revision ID: 269a002f989d -Revises: 9bf80ba3635f -Create Date: 2021-03-28 14:36:59.103846 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import mysql - -# revision identifiers, used by Alembic. -revision = '269a002f989d' -down_revision = '9bf80ba3635f' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('playdates', sa.Column('track_id', sa.Integer(), nullable=True)) - op.create_foreign_key(None, 'playdates', 'tracks', ['track_id'], ['id']) - op.drop_constraint('tracks_ibfk_1', 'tracks', type_='foreignkey') - op.drop_column('tracks', 'playdates_id') - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('tracks', sa.Column('playdates_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True)) - op.create_foreign_key('tracks_ibfk_1', 'tracks', 'playdates', ['playdates_id'], ['id']) - op.drop_constraint(None, 'playdates', type_='foreignkey') - op.drop_column('playdates', 'track_id') - # ### end Alembic commands ### diff --git a/migrations/versions/29c0d7ffc741_drop_uniquerow_index_on_playlist_rows.py b/migrations/versions/29c0d7ffc741_drop_uniquerow_index_on_playlist_rows.py deleted file mode 100644 index e14e34c..0000000 --- a/migrations/versions/29c0d7ffc741_drop_uniquerow_index_on_playlist_rows.py +++ /dev/null @@ -1,24 +0,0 @@ -"""Drop uniquerow index on playlist_rows - -Revision ID: 29c0d7ffc741 -Revises: 3b063011ed67 -Create Date: 2022-08-06 22:21:46.881378 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '29c0d7ffc741' -down_revision = '3b063011ed67' -branch_labels = None -depends_on = None - - -def upgrade(): - op.drop_index('uniquerow', table_name='playlist_rows') - - -def downgrade(): - op.create_index('uniquerow', 'playlist_rows', ['row_number', 'playlist_id'], unique=True) diff --git a/migrations/versions/2caa3d37f211_add_tracks_intro_column.py b/migrations/versions/2caa3d37f211_add_tracks_intro_column.py deleted file mode 100644 index c3a68da..0000000 --- a/migrations/versions/2caa3d37f211_add_tracks_intro_column.py +++ /dev/null @@ -1,110 +0,0 @@ -"""add Tracks.intro column - -Revision ID: 2caa3d37f211 -Revises: 5bb2c572e1e5 -Create Date: 2024-05-07 20:06:00.845979 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import mysql - -# revision identifiers, used by Alembic. -revision = '2caa3d37f211' -down_revision = '5bb2c572e1e5' -branch_labels = None -depends_on = None - - -def upgrade(engine_name: str) -> None: - globals()["upgrade_%s" % engine_name]() - - -def downgrade(engine_name: str) -> None: - globals()["downgrade_%s" % engine_name]() - - - - - -def upgrade_() -> None: - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('carts', schema=None) as batch_op: - batch_op.alter_column('name', - existing_type=mysql.VARCHAR(length=256), - nullable=False) - - with op.batch_alter_table('notecolours', schema=None) as batch_op: - batch_op.alter_column('substring', - existing_type=mysql.VARCHAR(length=256), - nullable=False) - batch_op.alter_column('colour', - existing_type=mysql.VARCHAR(length=21), - nullable=False) - batch_op.alter_column('enabled', - existing_type=mysql.TINYINT(display_width=1), - nullable=False) - batch_op.alter_column('is_regex', - existing_type=mysql.TINYINT(display_width=1), - nullable=False) - batch_op.alter_column('is_casesensitive', - existing_type=mysql.TINYINT(display_width=1), - nullable=False) - - with op.batch_alter_table('playdates', schema=None) as batch_op: - batch_op.alter_column('lastplayed', - existing_type=mysql.DATETIME(), - nullable=False) - batch_op.alter_column('track_id', - existing_type=mysql.INTEGER(display_width=11), - nullable=False) - - with op.batch_alter_table('playlists', schema=None) as batch_op: - batch_op.drop_index('tab') - - with op.batch_alter_table('tracks', schema=None) as batch_op: - batch_op.add_column(sa.Column('intro', sa.Integer(), nullable=True)) - - # ### end Alembic commands ### - - -def downgrade_() -> None: - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('tracks', schema=None) as batch_op: - batch_op.drop_column('intro') - - with op.batch_alter_table('playlists', schema=None) as batch_op: - batch_op.create_index('tab', ['tab'], unique=True) - - with op.batch_alter_table('playdates', schema=None) as batch_op: - batch_op.alter_column('track_id', - existing_type=mysql.INTEGER(display_width=11), - nullable=True) - batch_op.alter_column('lastplayed', - existing_type=mysql.DATETIME(), - nullable=True) - - with op.batch_alter_table('notecolours', schema=None) as batch_op: - batch_op.alter_column('is_casesensitive', - existing_type=mysql.TINYINT(display_width=1), - nullable=True) - batch_op.alter_column('is_regex', - existing_type=mysql.TINYINT(display_width=1), - nullable=True) - batch_op.alter_column('enabled', - existing_type=mysql.TINYINT(display_width=1), - nullable=True) - batch_op.alter_column('colour', - existing_type=mysql.VARCHAR(length=21), - nullable=True) - batch_op.alter_column('substring', - existing_type=mysql.VARCHAR(length=256), - nullable=True) - - with op.batch_alter_table('carts', schema=None) as batch_op: - batch_op.alter_column('name', - existing_type=mysql.VARCHAR(length=256), - nullable=True) - - # ### end Alembic commands ### - diff --git a/migrations/versions/2cc37d3cf07f_add_playlist_dates_and_loaded.py b/migrations/versions/2cc37d3cf07f_add_playlist_dates_and_loaded.py deleted file mode 100644 index 5a39927..0000000 --- a/migrations/versions/2cc37d3cf07f_add_playlist_dates_and_loaded.py +++ /dev/null @@ -1,30 +0,0 @@ -"""Add playlist dates and loaded - -Revision ID: 2cc37d3cf07f -Revises: e3b04db5506f -Create Date: 2021-04-27 21:55:50.639406 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = "2cc37d3cf07f" -down_revision = "e3b04db5506f" -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column("playlists", sa.Column("last_used", sa.DateTime(), nullable=True)) - op.add_column("playlists", sa.Column("loaded", sa.Boolean(), nullable=True)) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column("playlists", "loaded") - op.drop_column("playlists", "last_used") - # ### end Alembic commands ### diff --git a/migrations/versions/3a53a9fb26ab_migrate_sqla_2_and_remove_redundant_.py b/migrations/versions/3a53a9fb26ab_migrate_sqla_2_and_remove_redundant_.py deleted file mode 100644 index 336c0e4..0000000 --- a/migrations/versions/3a53a9fb26ab_migrate_sqla_2_and_remove_redundant_.py +++ /dev/null @@ -1,72 +0,0 @@ -"""Migrate SQLA 2 and remove redundant columns - -Revision ID: 3a53a9fb26ab -Revises: 07dcbe6c4f0e -Create Date: 2023-10-15 09:39:16.449419 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import mysql - -# revision identifiers, used by Alembic. -revision = '3a53a9fb26ab' -down_revision = '07dcbe6c4f0e' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('playlists', 'query') - op.drop_column('playlists', 'sort_column') - op.alter_column('tracks', 'title', - existing_type=mysql.VARCHAR(length=256), - nullable=False) - op.alter_column('tracks', 'artist', - existing_type=mysql.VARCHAR(length=256), - nullable=False) - op.alter_column('tracks', 'duration', - existing_type=mysql.INTEGER(display_width=11), - nullable=False) - op.alter_column('tracks', 'start_gap', - existing_type=mysql.INTEGER(display_width=11), - nullable=False) - op.alter_column('tracks', 'fade_at', - existing_type=mysql.INTEGER(display_width=11), - nullable=False) - op.alter_column('tracks', 'silence_at', - existing_type=mysql.INTEGER(display_width=11), - nullable=False) - op.alter_column('tracks', 'mtime', - existing_type=mysql.FLOAT(), - nullable=False) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('tracks', 'mtime', - existing_type=mysql.FLOAT(), - nullable=True) - op.alter_column('tracks', 'silence_at', - existing_type=mysql.INTEGER(display_width=11), - nullable=True) - op.alter_column('tracks', 'fade_at', - existing_type=mysql.INTEGER(display_width=11), - nullable=True) - op.alter_column('tracks', 'start_gap', - existing_type=mysql.INTEGER(display_width=11), - nullable=True) - op.alter_column('tracks', 'duration', - existing_type=mysql.INTEGER(display_width=11), - nullable=True) - op.alter_column('tracks', 'artist', - existing_type=mysql.VARCHAR(length=256), - nullable=True) - op.alter_column('tracks', 'title', - existing_type=mysql.VARCHAR(length=256), - nullable=True) - op.add_column('playlists', sa.Column('sort_column', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True)) - op.add_column('playlists', sa.Column('query', mysql.VARCHAR(length=256), nullable=True)) - # ### end Alembic commands ### diff --git a/migrations/versions/3b063011ed67_schema_changes_for_row_notes.py b/migrations/versions/3b063011ed67_schema_changes_for_row_notes.py deleted file mode 100644 index 587f7fa..0000000 --- a/migrations/versions/3b063011ed67_schema_changes_for_row_notes.py +++ /dev/null @@ -1,54 +0,0 @@ -"""schema changes for row notes - -Revision ID: 3b063011ed67 -Revises: 51f61433256f -Create Date: 2022-07-06 19:48:23.960471 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import mysql - -# revision identifiers, used by Alembic. -revision = '3b063011ed67' -down_revision = '51f61433256f' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('notes') - op.add_column('playlist_rows', sa.Column('note', sa.String(length=2048), nullable=True)) - op.alter_column('playlist_rows', 'track_id', - existing_type=mysql.INTEGER(display_width=11), - nullable=True) - op.drop_index('uniquerow', table_name='playlist_rows') - op.drop_column('playlist_rows', 'text') - op.alter_column('playlist_rows', 'row', new_column_name='row_number', - existing_type=mysql.INTEGER(display_width=11), - nullable=False) - op.create_index('uniquerow', 'playlist_rows', ['row_number', 'playlist_id'], unique=True) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('playlist_rows', 'row_number', new_column_name='row', - existing_type=mysql.INTEGER(display_width=11), - nullable=False) - op.add_column('playlist_rows', sa.Column('text', mysql.VARCHAR(length=2048), nullable=True)) - op.drop_index('uniquerow', table_name='playlist_rows') - op.create_index('uniquerow', 'playlist_rows', ['row', 'playlist_id'], unique=False) - op.drop_column('playlist_rows', 'note') - op.create_table('notes', - sa.Column('id', mysql.INTEGER(display_width=11), autoincrement=True, nullable=False), - sa.Column('playlist_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True), - sa.Column('row', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False), - sa.Column('note', mysql.VARCHAR(length=256), nullable=True), - sa.ForeignKeyConstraint(['playlist_id'], ['playlists.id'], name='notes_ibfk_1'), - sa.PrimaryKeyConstraint('id'), - mysql_default_charset='utf8mb4', - mysql_engine='InnoDB' - ) - # ### end Alembic commands ### diff --git a/migrations/versions/3f55ac7d80ad_rename_playlist_tracks_to_playlist_rows.py b/migrations/versions/3f55ac7d80ad_rename_playlist_tracks_to_playlist_rows.py deleted file mode 100644 index 6a2f153..0000000 --- a/migrations/versions/3f55ac7d80ad_rename_playlist_tracks_to_playlist_rows.py +++ /dev/null @@ -1,26 +0,0 @@ -"""Rename playlist_tracks to playlist_rows - -Revision ID: 3f55ac7d80ad -Revises: 1c4048efee96 -Create Date: 2022-07-04 20:51:59.874004 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '3f55ac7d80ad' -down_revision = '1c4048efee96' -branch_labels = None -depends_on = None - - -def upgrade(): - # Rename so as not to lose content - op.rename_table('playlist_tracks', 'playlist_rows') - - -def downgrade(): - # Rename so as not to lose content - op.rename_table('playlist_rows', 'playlist_tracks') diff --git a/migrations/versions/4a7b4ab3354f_record_tab_number_for_open_playlists.py b/migrations/versions/4a7b4ab3354f_record_tab_number_for_open_playlists.py deleted file mode 100644 index de573c0..0000000 --- a/migrations/versions/4a7b4ab3354f_record_tab_number_for_open_playlists.py +++ /dev/null @@ -1,32 +0,0 @@ -"""Record tab number for open playlists - -Revision ID: 4a7b4ab3354f -Revises: 6730f03317df -Create Date: 2022-12-20 15:38:28.318280 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import mysql - -# revision identifiers, used by Alembic. -revision = '4a7b4ab3354f' -down_revision = '6730f03317df' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('playlists', sa.Column('tab', sa.Integer(), nullable=True)) - op.create_unique_constraint(None, 'playlists', ['tab']) - op.drop_column('playlists', 'loaded') - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('playlists', sa.Column('loaded', mysql.TINYINT(display_width=1), autoincrement=False, nullable=False)) - op.drop_constraint(None, 'playlists', type_='unique') - op.drop_column('playlists', 'tab') - # ### end Alembic commands ### diff --git a/migrations/versions/51f61433256f_increase_settings_name_len_and_add_.py b/migrations/versions/51f61433256f_increase_settings_name_len_and_add_.py deleted file mode 100644 index dda10e3..0000000 --- a/migrations/versions/51f61433256f_increase_settings_name_len_and_add_.py +++ /dev/null @@ -1,34 +0,0 @@ -"""Increase settings.name len and add playlist_rows.notes - -Revision ID: 51f61433256f -Revises: 3f55ac7d80ad -Create Date: 2022-07-04 21:21:39.830406 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import mysql - -# revision identifiers, used by Alembic. -revision = '51f61433256f' -down_revision = '3f55ac7d80ad' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('playlist_rows', sa.Column('text', sa.String(length=2048), nullable=True)) - op.alter_column('playlists', 'loaded', - existing_type=mysql.TINYINT(display_width=1), - nullable=False) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('playlists', 'loaded', - existing_type=mysql.TINYINT(display_width=1), - nullable=True) - op.drop_column('playlist_rows', 'text') - # ### end Alembic commands ### diff --git a/migrations/versions/52cbded98e7c_update_notecolours_table.py b/migrations/versions/52cbded98e7c_update_notecolours_table.py deleted file mode 100644 index b7a4e64..0000000 --- a/migrations/versions/52cbded98e7c_update_notecolours_table.py +++ /dev/null @@ -1,30 +0,0 @@ -"""Update notecolours table - -Revision ID: 52cbded98e7c -Revises: c55992d1fe5f -Create Date: 2022-02-06 12:34:30.099417 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import mysql - -# revision identifiers, used by Alembic. -revision = '52cbded98e7c' -down_revision = 'c55992d1fe5f' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('notecolours', sa.Column('colour', sa.String(length=21), nullable=True)) - op.drop_column('notecolours', 'hexcolour') - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('notecolours', sa.Column('hexcolour', mysql.VARCHAR(length=6), nullable=True)) - op.drop_column('notecolours', 'colour') - # ### end Alembic commands ### diff --git a/migrations/versions/52d82712d218_initial.py b/migrations/versions/52d82712d218_initial.py deleted file mode 100644 index 812c4e3..0000000 --- a/migrations/versions/52d82712d218_initial.py +++ /dev/null @@ -1,24 +0,0 @@ -"""Initial - -Revision ID: 52d82712d218 -Revises: -Create Date: 2021-03-22 22:16:03.272827 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '52d82712d218' -down_revision = None -branch_labels = None -depends_on = None - - -def upgrade(): - pass - - -def downgrade(): - pass diff --git a/migrations/versions/5bb2c572e1e5_add_open_field_to_playlists.py b/migrations/versions/5bb2c572e1e5_add_open_field_to_playlists.py deleted file mode 100644 index f532b8e..0000000 --- a/migrations/versions/5bb2c572e1e5_add_open_field_to_playlists.py +++ /dev/null @@ -1,60 +0,0 @@ -"""Add 'open' field to Playlists - -Revision ID: 5bb2c572e1e5 -Revises: 3a53a9fb26ab -Create Date: 2023-11-18 14:19:02.643914 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import mysql - -# revision identifiers, used by Alembic. -revision = '5bb2c572e1e5' -down_revision = '3a53a9fb26ab' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('carts', 'duration', - existing_type=mysql.INTEGER(display_width=11), - nullable=True) - op.alter_column('carts', 'path', - existing_type=mysql.VARCHAR(length=2048), - nullable=True) - op.alter_column('carts', 'enabled', - existing_type=mysql.TINYINT(display_width=1), - nullable=True) - op.alter_column('playlist_rows', 'note', - existing_type=mysql.VARCHAR(length=2048), - nullable=False) - op.add_column('playlists', sa.Column('open', sa.Boolean(), nullable=False)) - op.alter_column('settings', 'name', - existing_type=mysql.VARCHAR(length=32), - type_=sa.String(length=64), - existing_nullable=False) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('settings', 'name', - existing_type=sa.String(length=64), - type_=mysql.VARCHAR(length=32), - existing_nullable=False) - op.drop_column('playlists', 'open') - op.alter_column('playlist_rows', 'note', - existing_type=mysql.VARCHAR(length=2048), - nullable=True) - op.alter_column('carts', 'enabled', - existing_type=mysql.TINYINT(display_width=1), - nullable=False) - op.alter_column('carts', 'path', - existing_type=mysql.VARCHAR(length=2048), - nullable=False) - op.alter_column('carts', 'duration', - existing_type=mysql.INTEGER(display_width=11), - nullable=False) - # ### end Alembic commands ### diff --git a/migrations/versions/6730f03317df_add_carts.py b/migrations/versions/6730f03317df_add_carts.py deleted file mode 100644 index e66f706..0000000 --- a/migrations/versions/6730f03317df_add_carts.py +++ /dev/null @@ -1,41 +0,0 @@ -"""Add carts - -Revision ID: 6730f03317df -Revises: b4f524e2140c -Create Date: 2022-09-13 19:41:33.181752 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '6730f03317df' -down_revision = 'b4f524e2140c' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('carts', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('cart_number', sa.Integer(), nullable=False), - sa.Column('name', sa.String(length=256), nullable=True), - sa.Column('duration', sa.Integer(), nullable=True), - sa.Column('path', sa.String(length=2048), nullable=True), - sa.Column('enabled', sa.Boolean(), nullable=False), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('cart_number') - ) - op.create_index(op.f('ix_carts_duration'), 'carts', ['duration'], unique=False) - op.create_index(op.f('ix_carts_name'), 'carts', ['name'], unique=False) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_index(op.f('ix_carts_name'), table_name='carts') - op.drop_index(op.f('ix_carts_duration'), table_name='carts') - op.drop_table('carts') - # ### end Alembic commands ### diff --git a/migrations/versions/708a21f5c271_initial_migration.py b/migrations/versions/708a21f5c271_initial_migration.py new file mode 100644 index 0000000..30e74ab --- /dev/null +++ b/migrations/versions/708a21f5c271_initial_migration.py @@ -0,0 +1,75 @@ +"""Initial migration + +Revision ID: 708a21f5c271 +Revises: +Create Date: 2024-12-14 11:16:09.067598 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import mysql + +# revision identifiers, used by Alembic. +revision = '708a21f5c271' +down_revision = None +branch_labels = None +depends_on = None + + +def upgrade(engine_name: str) -> None: + globals()["upgrade_%s" % engine_name]() + + +def downgrade(engine_name: str) -> None: + globals()["downgrade_%s" % engine_name]() + + + + + +def upgrade_() -> None: + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('carts', schema=None) as batch_op: + batch_op.drop_index('cart_number') + batch_op.drop_index('ix_carts_duration') + batch_op.drop_index('ix_carts_name') + + op.drop_table('carts') + with op.batch_alter_table('notecolours', schema=None) as batch_op: + batch_op.add_column(sa.Column('foreground', sa.String(length=21), nullable=True)) + + with op.batch_alter_table('playlist_rows', schema=None) as batch_op: + batch_op.create_index(batch_op.f('ix_playlist_rows_playlist_id'), ['playlist_id'], unique=False) + batch_op.create_index(batch_op.f('ix_playlist_rows_row_number'), ['row_number'], unique=False) + + # ### end Alembic commands ### + + +def downgrade_() -> None: + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('playlist_rows', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_playlist_rows_row_number')) + batch_op.drop_index(batch_op.f('ix_playlist_rows_playlist_id')) + + with op.batch_alter_table('notecolours', schema=None) as batch_op: + batch_op.drop_column('foreground') + + op.create_table('carts', + sa.Column('id', mysql.INTEGER(display_width=11), autoincrement=True, nullable=False), + sa.Column('cart_number', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False), + sa.Column('name', mysql.VARCHAR(length=256), nullable=False), + sa.Column('duration', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True), + sa.Column('path', mysql.VARCHAR(length=2048), nullable=True), + sa.Column('enabled', mysql.TINYINT(display_width=1), autoincrement=False, nullable=True), + sa.PrimaryKeyConstraint('id'), + mysql_collate='utf8mb4_general_ci', + mysql_default_charset='utf8mb4', + mysql_engine='InnoDB' + ) + with op.batch_alter_table('carts', schema=None) as batch_op: + batch_op.create_index('ix_carts_name', ['name'], unique=False) + batch_op.create_index('ix_carts_duration', ['duration'], unique=False) + batch_op.create_index('cart_number', ['cart_number'], unique=True) + + # ### end Alembic commands ### + diff --git a/migrations/versions/9bf80ba3635f_add_id_to_playlist_association_table.py b/migrations/versions/9bf80ba3635f_add_id_to_playlist_association_table.py deleted file mode 100644 index 878855f..0000000 --- a/migrations/versions/9bf80ba3635f_add_id_to_playlist_association_table.py +++ /dev/null @@ -1,34 +0,0 @@ -"""Add id to playlist association table - -Revision ID: 9bf80ba3635f -Revises: f071129cbd93 -Create Date: 2021-03-28 12:16:14.631579 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '9bf80ba3635f' -down_revision = 'f071129cbd93' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - conn = op.get_bind() - conn.execute( - "ALTER TABLE playlistracks ADD id INT PRIMARY KEY AUTO_INCREMENT FIRST" - ) - conn.execute("RENAME TABLE playlistracks TO playlisttracks") - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - conn = op.get_bind() - conn.execute("ALTER TABLE playlistracks DROP id") - conn.execute("RENAME TABLE playlisttracks TO playlistracks") - # ### end Alembic commands ### diff --git a/migrations/versions/a5aada49f2fc_add_notecolours_table.py b/migrations/versions/a5aada49f2fc_add_notecolours_table.py deleted file mode 100644 index 77490de..0000000 --- a/migrations/versions/a5aada49f2fc_add_notecolours_table.py +++ /dev/null @@ -1,36 +0,0 @@ -"""Add NoteColours table - -Revision ID: a5aada49f2fc -Revises: 2cc37d3cf07f -Create Date: 2022-02-05 17:34:54.880473 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'a5aada49f2fc' -down_revision = '2cc37d3cf07f' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('notecolours', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('substring', sa.String(length=256), nullable=True), - sa.Column('hexcolour', sa.String(length=6), nullable=True), - sa.Column('enabled', sa.Boolean(), nullable=True), - sa.Column('is_regex', sa.Boolean(), nullable=True), - sa.Column('is_casesensitive', sa.Boolean(), nullable=True), - sa.PrimaryKeyConstraint('id') - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('notecolours') - # ### end Alembic commands ### diff --git a/migrations/versions/b0983648595e_add_settings_table.py b/migrations/versions/b0983648595e_add_settings_table.py deleted file mode 100644 index 34ef976..0000000 --- a/migrations/versions/b0983648595e_add_settings_table.py +++ /dev/null @@ -1,37 +0,0 @@ -"""Add settings table - -Revision ID: b0983648595e -Revises: 1bc727e5e87f -Create Date: 2021-03-26 13:33:41.994508 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = "b0983648595e" -down_revision = "1bc727e5e87f" -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table( - "settings", - sa.Column("id", sa.Integer(), autoincrement=True, nullable=False), - sa.Column("name", sa.String(length=32), nullable=False), - sa.Column("f_datetime", sa.DateTime(), nullable=True), - sa.Column("f_int", sa.Integer(), nullable=True), - sa.Column("f_string", sa.String(length=128), nullable=True), - sa.PrimaryKeyConstraint("id"), - sa.UniqueConstraint("name"), - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table("settings") - # ### end Alembic commands ### diff --git a/migrations/versions/b4f524e2140c_add_templates.py b/migrations/versions/b4f524e2140c_add_templates.py deleted file mode 100644 index 2523174..0000000 --- a/migrations/versions/b4f524e2140c_add_templates.py +++ /dev/null @@ -1,32 +0,0 @@ -"""Add templates - -Revision ID: b4f524e2140c -Revises: ed3100326c38 -Create Date: 2022-10-01 13:30:21.663287 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'b4f524e2140c' -down_revision = 'ed3100326c38' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_foreign_key(None, 'playlist_rows', 'tracks', ['track_id'], ['id']) - op.create_foreign_key(None, 'playlist_rows', 'playlists', ['playlist_id'], ['id']) - op.add_column('playlists', sa.Column('is_template', sa.Boolean(), nullable=False)) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('playlists', 'is_template') - op.drop_constraint(None, 'playlist_rows', type_='foreignkey') - op.drop_constraint(None, 'playlist_rows', type_='foreignkey') - # ### end Alembic commands ### diff --git a/migrations/versions/c55992d1fe5f_add_order_to_colours_table.py b/migrations/versions/c55992d1fe5f_add_order_to_colours_table.py deleted file mode 100644 index 376b7b3..0000000 --- a/migrations/versions/c55992d1fe5f_add_order_to_colours_table.py +++ /dev/null @@ -1,32 +0,0 @@ -"""Add order to colours table - -Revision ID: c55992d1fe5f -Revises: a5aada49f2fc -Create Date: 2022-02-05 21:28:36.391312 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'c55992d1fe5f' -down_revision = 'a5aada49f2fc' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('notecolours', sa.Column('order', sa.Integer(), nullable=True)) - op.create_index(op.f('ix_notecolours_enabled'), 'notecolours', ['enabled'], unique=False) - op.create_index(op.f('ix_notecolours_order'), 'notecolours', ['order'], unique=False) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_index(op.f('ix_notecolours_order'), table_name='notecolours') - op.drop_index(op.f('ix_notecolours_enabled'), table_name='notecolours') - op.drop_column('notecolours', 'order') - # ### end Alembic commands ### diff --git a/migrations/versions/e3b04db5506f_add_structure_for_notes.py b/migrations/versions/e3b04db5506f_add_structure_for_notes.py deleted file mode 100644 index 5af0ab1..0000000 --- a/migrations/versions/e3b04db5506f_add_structure_for_notes.py +++ /dev/null @@ -1,51 +0,0 @@ -"""Add structure for notes - -Revision ID: e3b04db5506f -Revises: 269a002f989d -Create Date: 2021-04-05 16:33:50.117747 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import mysql - -# revision identifiers, used by Alembic. -revision = 'e3b04db5506f' -down_revision = '269a002f989d' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('notes', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('playlist_id', sa.Integer(), nullable=True), - sa.Column('row', sa.Integer(), nullable=False), - sa.Column('note', sa.String(length=256), nullable=True), - sa.ForeignKeyConstraint(['playlist_id'], ['playlists.id'], ), - sa.PrimaryKeyConstraint('id') - ) - op.add_column('playlisttracks', sa.Column('row', sa.Integer(), nullable=False)) - op.alter_column('playlisttracks', 'playlist_id', - existing_type=mysql.INTEGER(display_width=11), - nullable=False) - op.alter_column('playlisttracks', 'track_id', - existing_type=mysql.INTEGER(display_width=11), - nullable=False) - op.drop_column('playlisttracks', 'sort') - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('playlisttracks', sa.Column('sort', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False)) - op.alter_column('playlisttracks', 'track_id', - existing_type=mysql.INTEGER(display_width=11), - nullable=True) - op.alter_column('playlisttracks', 'playlist_id', - existing_type=mysql.INTEGER(display_width=11), - nullable=True) - op.drop_column('playlisttracks', 'row') - op.drop_table('notes') - # ### end Alembic commands ### diff --git a/migrations/versions/ed3100326c38_add_column_for_bitrate_in_tracks.py b/migrations/versions/ed3100326c38_add_column_for_bitrate_in_tracks.py deleted file mode 100644 index e2a51e3..0000000 --- a/migrations/versions/ed3100326c38_add_column_for_bitrate_in_tracks.py +++ /dev/null @@ -1,28 +0,0 @@ -"""Add column for bitrate in Tracks - -Revision ID: ed3100326c38 -Revises: fe2e127b3332 -Create Date: 2022-08-22 16:16:42.181848 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'ed3100326c38' -down_revision = 'fe2e127b3332' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('tracks', sa.Column('bitrate', sa.Integer(), nullable=True)) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('tracks', 'bitrate') - # ### end Alembic commands ### diff --git a/migrations/versions/f071129cbd93_add_sort_to_playlist_association_table.py b/migrations/versions/f071129cbd93_add_sort_to_playlist_association_table.py deleted file mode 100644 index b7736ff..0000000 --- a/migrations/versions/f071129cbd93_add_sort_to_playlist_association_table.py +++ /dev/null @@ -1,28 +0,0 @@ -"""Add sort to playlist association table - -Revision ID: f071129cbd93 -Revises: f07b96a5e60f -Create Date: 2021-03-28 11:19:31.944110 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'f071129cbd93' -down_revision = 'f07b96a5e60f' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('playlistracks', sa.Column('sort', sa.Integer(), nullable=False)) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('playlistracks', 'sort') - # ### end Alembic commands ### diff --git a/migrations/versions/f07b96a5e60f_add_playlist_and_playtimes.py b/migrations/versions/f07b96a5e60f_add_playlist_and_playtimes.py deleted file mode 100644 index e3c3238..0000000 --- a/migrations/versions/f07b96a5e60f_add_playlist_and_playtimes.py +++ /dev/null @@ -1,63 +0,0 @@ -"""Add playlist and playtimes - -Revision ID: f07b96a5e60f -Revises: b0983648595e -Create Date: 2021-03-27 19:53:09.524989 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = "f07b96a5e60f" -down_revision = "b0983648595e" -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table( - "playdates", - sa.Column("id", sa.Integer(), autoincrement=True, nullable=False), - sa.Column("lastplayed", sa.DateTime(), nullable=True), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index( - op.f("ix_playdates_lastplayed"), "playdates", ["lastplayed"], unique=False - ) - op.create_table( - "playlists", - sa.Column("id", sa.Integer(), autoincrement=True, nullable=False), - sa.Column("name", sa.String(length=32), nullable=False), - sa.PrimaryKeyConstraint("id"), - sa.UniqueConstraint("name"), - ) - op.create_table( - "playlistracks", - sa.Column("playlist_id", sa.Integer(), nullable=True), - sa.Column("track_id", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint( - ["playlist_id"], - ["playlists.id"], - ), - sa.ForeignKeyConstraint( - ["track_id"], - ["tracks.id"], - ), - ) - op.add_column("tracks", sa.Column("playdates_id", sa.Integer(), nullable=True)) - op.create_foreign_key(None, "tracks", "playdates", ["playdates_id"], ["id"]) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint(None, "tracks", type_="foreignkey") - op.drop_column("tracks", "playdates_id") - op.drop_table("playlistracks") - op.drop_table("playlists") - op.drop_index(op.f("ix_playdates_lastplayed"), table_name="playdates") - op.drop_table("playdates") - # ### end Alembic commands ### diff --git a/migrations/versions/fe2e127b3332_don_t_allow_duplicate_track_paths.py b/migrations/versions/fe2e127b3332_don_t_allow_duplicate_track_paths.py deleted file mode 100644 index 4f515c3..0000000 --- a/migrations/versions/fe2e127b3332_don_t_allow_duplicate_track_paths.py +++ /dev/null @@ -1,28 +0,0 @@ -"""Don't allow duplicate track paths - -Revision ID: fe2e127b3332 -Revises: 0c604bf490f8 -Create Date: 2022-08-21 19:46:35.768659 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'fe2e127b3332' -down_revision = '0c604bf490f8' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_unique_constraint(None, 'tracks', ['path']) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint(None, 'tracks', type_='unique') - # ### end Alembic commands ###