From 639f006a100ad0b995484fbdd9de7ac5932a43c6 Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Sat, 22 Feb 2025 20:23:07 +0000 Subject: [PATCH] Add favourite to playlists --- app/dbtables.py | 3 + ...04df697e40cd_add_favouirit_to_playlists.py | 58 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 migrations/versions/04df697e40cd_add_favouirit_to_playlists.py diff --git a/app/dbtables.py b/app/dbtables.py index 176a346..4aa97f6 100644 --- a/app/dbtables.py +++ b/app/dbtables.py @@ -80,6 +80,9 @@ class PlaylistsTable(Model): cascade="all, delete-orphan", order_by="PlaylistRowsTable.row_number", ) + favourite: Mapped[bool] = mapped_column( + Boolean, nullable=False, index=False, default=False + ) def __repr__(self) -> str: return ( diff --git a/migrations/versions/04df697e40cd_add_favouirit_to_playlists.py b/migrations/versions/04df697e40cd_add_favouirit_to_playlists.py new file mode 100644 index 0000000..ea4fd70 --- /dev/null +++ b/migrations/versions/04df697e40cd_add_favouirit_to_playlists.py @@ -0,0 +1,58 @@ +"""add favouirit to playlists + +Revision ID: 04df697e40cd +Revises: 33c04e3c12c8 +Create Date: 2025-02-22 20:20:45.030024 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import mysql + +# revision identifiers, used by Alembic. +revision = '04df697e40cd' +down_revision = '33c04e3c12c8' +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('notecolours', schema=None) as batch_op: + batch_op.add_column(sa.Column('strip_substring', sa.Boolean(), nullable=False)) + batch_op.create_index(batch_op.f('ix_notecolours_substring'), ['substring'], unique=False) + + with op.batch_alter_table('playlist_rows', schema=None) as batch_op: + batch_op.drop_constraint('playlist_rows_ibfk_1', type_='foreignkey') + + with op.batch_alter_table('playlists', schema=None) as batch_op: + batch_op.add_column(sa.Column('favourite', sa.Boolean(), nullable=False)) + + # ### end Alembic commands ### + + +def downgrade_() -> None: + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('playlists', schema=None) as batch_op: + batch_op.drop_column('favourite') + + with op.batch_alter_table('playlist_rows', schema=None) as batch_op: + batch_op.create_foreign_key('playlist_rows_ibfk_1', 'tracks', ['track_id'], ['id']) + + with op.batch_alter_table('notecolours', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_notecolours_substring')) + batch_op.drop_column('strip_substring') + + # ### end Alembic commands ### +