This commit is contained in:
Kamil
2024-11-22 12:29:29 +00:00
parent 4be8622bcd
commit 435f903b94
62 changed files with 3690 additions and 168 deletions

View File

@@ -0,0 +1,75 @@
"""Added Playlist and Track models, relationships
Revision ID: 05f2ef26e1a8
Revises: dfcca9d99ce7
Create Date: 2024-10-10 12:09:05.659154
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '05f2ef26e1a8'
down_revision = 'dfcca9d99ce7'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('jellyfin_user',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=100), nullable=False),
sa.Column('jellyfin_user_id', sa.String(length=120), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('jellyfin_user_id'),
sa.UniqueConstraint('name')
)
op.create_table('playlist',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=150), nullable=False),
sa.Column('spotify_playlist_id', sa.String(length=120), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('spotify_playlist_id')
)
op.create_table('track',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=150), nullable=False),
sa.Column('spotify_track_id', sa.String(length=120), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('spotify_track_id')
)
op.create_table('playlist_tracks',
sa.Column('playlist_id', sa.Integer(), nullable=False),
sa.Column('track_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['playlist_id'], ['playlist.id'], ),
sa.ForeignKeyConstraint(['track_id'], ['track.id'], ),
sa.PrimaryKeyConstraint('playlist_id', 'track_id')
)
op.create_table('user_playlists',
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('playlist_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['playlist_id'], ['playlist.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['jellyfin_user.id'], ),
sa.PrimaryKeyConstraint('user_id', 'playlist_id')
)
op.drop_table('user')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('user',
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column('name', sa.VARCHAR(length=100), autoincrement=False, nullable=False),
sa.Column('email', sa.VARCHAR(length=120), autoincrement=False, nullable=False),
sa.PrimaryKeyConstraint('id', name='user_pkey'),
sa.UniqueConstraint('email', name='user_email_key')
)
op.drop_table('user_playlists')
op.drop_table('playlist_tracks')
op.drop_table('track')
op.drop_table('playlist')
op.drop_table('jellyfin_user')
# ### end Alembic commands ###

View File

@@ -0,0 +1,38 @@
"""Add jellyfin_id to Track and user_playlists
Revision ID: 2b8f75ed0a54
Revises: 70b2970ce195
Create Date: 2024-10-22 17:16:37.844073
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '2b8f75ed0a54'
down_revision = '70b2970ce195'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('track', schema=None) as batch_op:
batch_op.add_column(sa.Column('jellyfin_id', sa.String(length=120), nullable=True))
with op.batch_alter_table('user_playlists', schema=None) as batch_op:
batch_op.add_column(sa.Column('jellyfin_id', sa.String(length=120), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('user_playlists', schema=None) as batch_op:
batch_op.drop_column('jellyfin_id')
with op.batch_alter_table('track', schema=None) as batch_op:
batch_op.drop_column('jellyfin_id')
# ### end Alembic commands ###

View File

@@ -0,0 +1,32 @@
"""Add track_order
Revision ID: 30e948342792
Revises: 95f1a12a7da3
Create Date: 2024-10-23 13:56:43.511626
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '30e948342792'
down_revision = '95f1a12a7da3'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('playlist_tracks', schema=None) as batch_op:
batch_op.add_column(sa.Column('track_order', sa.Integer(), nullable=False))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('playlist_tracks', schema=None) as batch_op:
batch_op.drop_column('track_order')
# ### end Alembic commands ###

View File

@@ -0,0 +1,38 @@
"""extend download status
Revision ID: 41cfd15a9050
Revises: a1478d4d2c47
Create Date: 2024-10-26 11:35:42.853550
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '41cfd15a9050'
down_revision = 'a1478d4d2c47'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('track', schema=None) as batch_op:
batch_op.alter_column('download_status',
existing_type=sa.VARCHAR(length=200),
type_=sa.String(length=2048),
existing_nullable=True)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('track', schema=None) as batch_op:
batch_op.alter_column('download_status',
existing_type=sa.String(length=2048),
type_=sa.VARCHAR(length=200),
existing_nullable=True)
# ### end Alembic commands ###

View File

@@ -0,0 +1,34 @@
"""Added spotify_u12ri
Revision ID: 52d71c294c8f
Revises: 8843534fa7ea
Create Date: 2024-10-10 13:38:07.247311
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '52d71c294c8f'
down_revision = '8843534fa7ea'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('track', schema=None) as batch_op:
batch_op.add_column(sa.Column('downloaded', sa.Boolean(), nullable=True))
batch_op.add_column(sa.Column('filesystem_path', sa.String(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('track', schema=None) as batch_op:
batch_op.drop_column('filesystem_path')
batch_op.drop_column('downloaded')
# ### end Alembic commands ###

View File

@@ -0,0 +1,38 @@
"""Add jellyfin_id to Playlists, remove jellyfin_id from user_playlists, the second again
Revision ID: 5a06403b57cf
Revises: 6089eb604dbf
Create Date: 2024-10-23 08:32:11.962812
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '5a06403b57cf'
down_revision = '6089eb604dbf'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('playlist', schema=None) as batch_op:
batch_op.add_column(sa.Column('jellyfin_id', sa.String(length=120), nullable=True))
with op.batch_alter_table('user_playlists', schema=None) as batch_op:
batch_op.drop_column('jellyfin_id')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('user_playlists', schema=None) as batch_op:
batch_op.add_column(sa.Column('jellyfin_id', sa.VARCHAR(length=120), autoincrement=False, nullable=True))
with op.batch_alter_table('playlist', schema=None) as batch_op:
batch_op.drop_column('jellyfin_id')
# ### end Alembic commands ###

View File

@@ -0,0 +1,38 @@
"""Add jellyfin_id to Track and user_playlists, second
Revision ID: 6089eb604dbf
Revises: 7cc06fc32cc7
Create Date: 2024-10-22 21:08:41.605515
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '6089eb604dbf'
down_revision = '7cc06fc32cc7'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('playlist', schema=None) as batch_op:
batch_op.drop_column('jellyfin_id')
with op.batch_alter_table('user_playlists', schema=None) as batch_op:
batch_op.add_column(sa.Column('jellyfin_id', sa.String(length=120), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('user_playlists', schema=None) as batch_op:
batch_op.drop_column('jellyfin_id')
with op.batch_alter_table('playlist', schema=None) as batch_op:
batch_op.add_column(sa.Column('jellyfin_id', sa.VARCHAR(length=120), autoincrement=False, nullable=True))
# ### end Alembic commands ###

View File

@@ -0,0 +1,34 @@
"""Add track_count and tracks_available to Playlist
Revision ID: 70b2970ce195
Revises: 52d71c294c8f
Create Date: 2024-10-10 21:37:22.419162
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '70b2970ce195'
down_revision = '52d71c294c8f'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('playlist', schema=None) as batch_op:
batch_op.add_column(sa.Column('track_count', sa.Integer(), nullable=True))
batch_op.add_column(sa.Column('tracks_available', sa.Integer(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('playlist', schema=None) as batch_op:
batch_op.drop_column('tracks_available')
batch_op.drop_column('track_count')
# ### end Alembic commands ###

View File

@@ -0,0 +1,38 @@
"""Add jellyfin_id to Playlists, remove jellyfin_id from user_playlists
Revision ID: 7cc06fc32cc7
Revises: 2b8f75ed0a54
Create Date: 2024-10-22 17:24:39.761794
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '7cc06fc32cc7'
down_revision = '2b8f75ed0a54'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('playlist', schema=None) as batch_op:
batch_op.add_column(sa.Column('jellyfin_id', sa.String(length=120), nullable=True))
with op.batch_alter_table('user_playlists', schema=None) as batch_op:
batch_op.drop_column('jellyfin_id')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('user_playlists', schema=None) as batch_op:
batch_op.add_column(sa.Column('jellyfin_id', sa.VARCHAR(length=120), autoincrement=False, nullable=True))
with op.batch_alter_table('playlist', schema=None) as batch_op:
batch_op.drop_column('jellyfin_id')
# ### end Alembic commands ###

View File

@@ -0,0 +1,42 @@
"""Added spotify_uri
Revision ID: 8843534fa7ea
Revises: 05f2ef26e1a8
Create Date: 2024-10-10 13:27:34.675770
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '8843534fa7ea'
down_revision = '05f2ef26e1a8'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('playlist', schema=None) as batch_op:
batch_op.add_column(sa.Column('spotify_uri', sa.String(length=120), nullable=False))
batch_op.create_unique_constraint(None, ['spotify_uri'])
with op.batch_alter_table('track', schema=None) as batch_op:
batch_op.add_column(sa.Column('spotify_uri', sa.String(length=120), nullable=False))
batch_op.create_unique_constraint(None, ['spotify_uri'])
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('track', schema=None) as batch_op:
batch_op.drop_constraint(None, type_='unique')
batch_op.drop_column('spotify_uri')
with op.batch_alter_table('playlist', schema=None) as batch_op:
batch_op.drop_constraint(None, type_='unique')
batch_op.drop_column('spotify_uri')
# ### end Alembic commands ###

View File

@@ -0,0 +1,34 @@
"""Add last_updated and last_changed fields to Playlist model
Revision ID: 8fcd403f0c45
Revises: 41cfd15a9050
Create Date: 2024-11-21 16:09:39.875467
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '8fcd403f0c45'
down_revision = '41cfd15a9050'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('playlist', schema=None) as batch_op:
batch_op.add_column(sa.Column('last_updated', sa.DateTime(), nullable=True))
batch_op.add_column(sa.Column('last_changed', sa.DateTime(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('playlist', schema=None) as batch_op:
batch_op.drop_column('last_changed')
batch_op.drop_column('last_updated')
# ### end Alembic commands ###

View File

@@ -0,0 +1,32 @@
"""Add is_admin
Revision ID: 95f1a12a7da3
Revises: 5a06403b57cf
Create Date: 2024-10-23 09:55:36.772967
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '95f1a12a7da3'
down_revision = '5a06403b57cf'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('jellyfin_user', schema=None) as batch_op:
batch_op.add_column(sa.Column('is_admin', sa.Boolean(), nullable=False))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('jellyfin_user', schema=None) as batch_op:
batch_op.drop_column('is_admin')
# ### end Alembic commands ###

View File

@@ -0,0 +1,32 @@
"""Add download_Status
Revision ID: a1478d4d2c47
Revises: 30e948342792
Create Date: 2024-10-25 19:37:41.898682
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'a1478d4d2c47'
down_revision = '30e948342792'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('track', schema=None) as batch_op:
batch_op.add_column(sa.Column('download_status', sa.String(length=200), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('track', schema=None) as batch_op:
batch_op.drop_column('download_status')
# ### end Alembic commands ###

View File

@@ -0,0 +1,34 @@
"""Initial
Revision ID: dfcca9d99ce7
Revises:
Create Date: 2024-10-08 21:18:33.666046
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'dfcca9d99ce7'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('user',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=100), nullable=False),
sa.Column('email', sa.String(length=120), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('email')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('user')
# ### end Alembic commands ###