v0.1.0
This commit is contained in:
1
migrations/README
Normal file
1
migrations/README
Normal file
@@ -0,0 +1 @@
|
||||
Single-database configuration for Flask.
|
||||
50
migrations/alembic.ini
Normal file
50
migrations/alembic.ini
Normal file
@@ -0,0 +1,50 @@
|
||||
# A generic, single database configuration.
|
||||
|
||||
[alembic]
|
||||
# template used to generate migration files
|
||||
# file_template = %%(rev)s_%%(slug)s
|
||||
|
||||
# set to 'true' to run the environment during
|
||||
# the 'revision' command, regardless of autogenerate
|
||||
# revision_environment = false
|
||||
|
||||
|
||||
# Logging configuration
|
||||
[loggers]
|
||||
keys = root,sqlalchemy,alembic,flask_migrate
|
||||
|
||||
[handlers]
|
||||
keys = console
|
||||
|
||||
[formatters]
|
||||
keys = generic
|
||||
|
||||
[logger_root]
|
||||
level = WARN
|
||||
handlers = console
|
||||
qualname =
|
||||
|
||||
[logger_sqlalchemy]
|
||||
level = WARN
|
||||
handlers =
|
||||
qualname = sqlalchemy.engine
|
||||
|
||||
[logger_alembic]
|
||||
level = INFO
|
||||
handlers =
|
||||
qualname = alembic
|
||||
|
||||
[logger_flask_migrate]
|
||||
level = INFO
|
||||
handlers =
|
||||
qualname = flask_migrate
|
||||
|
||||
[handler_console]
|
||||
class = StreamHandler
|
||||
args = (sys.stderr,)
|
||||
level = NOTSET
|
||||
formatter = generic
|
||||
|
||||
[formatter_generic]
|
||||
format = %(levelname)-5.5s [%(name)s] %(message)s
|
||||
datefmt = %H:%M:%S
|
||||
113
migrations/env.py
Normal file
113
migrations/env.py
Normal file
@@ -0,0 +1,113 @@
|
||||
import logging
|
||||
from logging.config import fileConfig
|
||||
|
||||
from flask import current_app
|
||||
|
||||
from alembic import context
|
||||
|
||||
# this is the Alembic Config object, which provides
|
||||
# access to the values within the .ini file in use.
|
||||
config = context.config
|
||||
|
||||
# Interpret the config file for Python logging.
|
||||
# This line sets up loggers basically.
|
||||
fileConfig(config.config_file_name)
|
||||
logger = logging.getLogger('alembic.env')
|
||||
|
||||
|
||||
def get_engine():
|
||||
try:
|
||||
# this works with Flask-SQLAlchemy<3 and Alchemical
|
||||
return current_app.extensions['migrate'].db.get_engine()
|
||||
except (TypeError, AttributeError):
|
||||
# this works with Flask-SQLAlchemy>=3
|
||||
return current_app.extensions['migrate'].db.engine
|
||||
|
||||
|
||||
def get_engine_url():
|
||||
try:
|
||||
return get_engine().url.render_as_string(hide_password=False).replace(
|
||||
'%', '%%')
|
||||
except AttributeError:
|
||||
return str(get_engine().url).replace('%', '%%')
|
||||
|
||||
|
||||
# add your model's MetaData object here
|
||||
# for 'autogenerate' support
|
||||
# from myapp import mymodel
|
||||
# target_metadata = mymodel.Base.metadata
|
||||
config.set_main_option('sqlalchemy.url', get_engine_url())
|
||||
target_db = current_app.extensions['migrate'].db
|
||||
|
||||
# other values from the config, defined by the needs of env.py,
|
||||
# can be acquired:
|
||||
# my_important_option = config.get_main_option("my_important_option")
|
||||
# ... etc.
|
||||
|
||||
|
||||
def get_metadata():
|
||||
if hasattr(target_db, 'metadatas'):
|
||||
return target_db.metadatas[None]
|
||||
return target_db.metadata
|
||||
|
||||
|
||||
def run_migrations_offline():
|
||||
"""Run migrations in 'offline' mode.
|
||||
|
||||
This configures the context with just a URL
|
||||
and not an Engine, though an Engine is acceptable
|
||||
here as well. By skipping the Engine creation
|
||||
we don't even need a DBAPI to be available.
|
||||
|
||||
Calls to context.execute() here emit the given string to the
|
||||
script output.
|
||||
|
||||
"""
|
||||
url = config.get_main_option("sqlalchemy.url")
|
||||
context.configure(
|
||||
url=url, target_metadata=get_metadata(), literal_binds=True
|
||||
)
|
||||
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
|
||||
def run_migrations_online():
|
||||
"""Run migrations in 'online' mode.
|
||||
|
||||
In this scenario we need to create an Engine
|
||||
and associate a connection with the context.
|
||||
|
||||
"""
|
||||
|
||||
# this callback is used to prevent an auto-migration from being generated
|
||||
# when there are no changes to the schema
|
||||
# reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html
|
||||
def process_revision_directives(context, revision, directives):
|
||||
if getattr(config.cmd_opts, 'autogenerate', False):
|
||||
script = directives[0]
|
||||
if script.upgrade_ops.is_empty():
|
||||
directives[:] = []
|
||||
logger.info('No changes in schema detected.')
|
||||
|
||||
conf_args = current_app.extensions['migrate'].configure_args
|
||||
if conf_args.get("process_revision_directives") is None:
|
||||
conf_args["process_revision_directives"] = process_revision_directives
|
||||
|
||||
connectable = get_engine()
|
||||
|
||||
with connectable.connect() as connection:
|
||||
context.configure(
|
||||
connection=connection,
|
||||
target_metadata=get_metadata(),
|
||||
**conf_args
|
||||
)
|
||||
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
|
||||
if context.is_offline_mode():
|
||||
run_migrations_offline()
|
||||
else:
|
||||
run_migrations_online()
|
||||
24
migrations/script.py.mako
Normal file
24
migrations/script.py.mako
Normal file
@@ -0,0 +1,24 @@
|
||||
"""${message}
|
||||
|
||||
Revision ID: ${up_revision}
|
||||
Revises: ${down_revision | comma,n}
|
||||
Create Date: ${create_date}
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
${imports if imports else ""}
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = ${repr(up_revision)}
|
||||
down_revision = ${repr(down_revision)}
|
||||
branch_labels = ${repr(branch_labels)}
|
||||
depends_on = ${repr(depends_on)}
|
||||
|
||||
|
||||
def upgrade():
|
||||
${upgrades if upgrades else "pass"}
|
||||
|
||||
|
||||
def downgrade():
|
||||
${downgrades if downgrades else "pass"}
|
||||
@@ -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 ###
|
||||
@@ -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 ###
|
||||
32
migrations/versions/30e948342792_add_track_order.py
Normal file
32
migrations/versions/30e948342792_add_track_order.py
Normal 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 ###
|
||||
38
migrations/versions/41cfd15a9050_extend_download_status.py
Normal file
38
migrations/versions/41cfd15a9050_extend_download_status.py
Normal 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 ###
|
||||
34
migrations/versions/52d71c294c8f_added_spotify_u12ri.py
Normal file
34
migrations/versions/52d71c294c8f_added_spotify_u12ri.py
Normal 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 ###
|
||||
@@ -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 ###
|
||||
@@ -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 ###
|
||||
@@ -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 ###
|
||||
@@ -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 ###
|
||||
42
migrations/versions/8843534fa7ea_added_spotify_uri.py
Normal file
42
migrations/versions/8843534fa7ea_added_spotify_uri.py
Normal 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 ###
|
||||
@@ -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 ###
|
||||
32
migrations/versions/95f1a12a7da3_add_is_admin.py
Normal file
32
migrations/versions/95f1a12a7da3_add_is_admin.py
Normal 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 ###
|
||||
32
migrations/versions/a1478d4d2c47_add_download_status.py
Normal file
32
migrations/versions/a1478d4d2c47_add_download_status.py
Normal 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 ###
|
||||
34
migrations/versions/dfcca9d99ce7_initial.py
Normal file
34
migrations/versions/dfcca9d99ce7_initial.py
Normal 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 ###
|
||||
Reference in New Issue
Block a user