"""add clip, playlist and favorite

Revision ID: 50de163bd2ec
Revises: f2856ed33727
Create Date: 2021-07-15 23:19:52.819596

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '50de163bd2ec'
down_revision = 'f2856ed33727'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('playlist',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=128), nullable=False),
    sa.Column('comment', sa.Text(), nullable=True),
    sa.Column('author_id', sa.Integer(), nullable=True),
    sa.Column('is_public', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['user.id'], name=op.f('fk_playlist_author_id_user'), ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_playlist'))
    )
    with op.batch_alter_table('playlist', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_playlist_author_id'), ['author_id'], unique=False)

    op.create_table('clip',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('link', sa.String(length=128), nullable=False),
    sa.Column('name', sa.String(length=128), nullable=False),
    sa.Column('author_id', sa.Integer(), nullable=True),
    sa.Column('playlist_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['user.id'], name=op.f('fk_clip_author_id_user'), ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['playlist_id'], ['playlist.id'], name=op.f('fk_clip_playlist_id_playlist'), ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_clip'))
    )
    with op.batch_alter_table('clip', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_clip_author_id'), ['author_id'], unique=False)
        batch_op.create_index(batch_op.f('ix_clip_link'), ['link'], unique=True)
        batch_op.create_index(batch_op.f('ix_clip_playlist_id'), ['playlist_id'], unique=False)

    op.create_table('favorite',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('playlist_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['playlist_id'], ['playlist.id'], name=op.f('fk_favorite_playlist_id_playlist'), ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], name=op.f('fk_favorite_user_id_user'), ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_favorite'))
    )
    with op.batch_alter_table('favorite', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_favorite_playlist_id'), ['playlist_id'], unique=False)
        batch_op.create_index(batch_op.f('ix_favorite_user_id'), ['user_id'], unique=False)

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('favorite', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_favorite_user_id'))
        batch_op.drop_index(batch_op.f('ix_favorite_playlist_id'))

    op.drop_table('favorite')
    with op.batch_alter_table('clip', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_clip_playlist_id'))
        batch_op.drop_index(batch_op.f('ix_clip_link'))
        batch_op.drop_index(batch_op.f('ix_clip_author_id'))

    op.drop_table('clip')
    with op.batch_alter_table('playlist', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_playlist_author_id'))

    op.drop_table('playlist')
    # ### end Alembic commands ###

08edc77235fdc59cc01839bfb4bec3fade0c058b
<mask token>


def downgrade():
    with op.batch_alter_table('favorite', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_favorite_user_id'))
        batch_op.drop_index(batch_op.f('ix_favorite_playlist_id'))
    op.drop_table('favorite')
    with op.batch_alter_table('clip', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_clip_playlist_id'))
        batch_op.drop_index(batch_op.f('ix_clip_link'))
        batch_op.drop_index(batch_op.f('ix_clip_author_id'))
    op.drop_table('clip')
    with op.batch_alter_table('playlist', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_playlist_author_id'))
    op.drop_table('playlist')

<mask token>


def upgrade():
    op.create_table('playlist', sa.Column('id', sa.Integer(), nullable=
        False), sa.Column('name', sa.String(length=128), nullable=False),
        sa.Column('comment', sa.Text(), nullable=True), sa.Column(
        'author_id', sa.Integer(), nullable=True), sa.Column('is_public',
        sa.Boolean(), nullable=True), sa.ForeignKeyConstraint(['author_id'],
        ['user.id'], name=op.f('fk_playlist_author_id_user'), ondelete=
        'CASCADE'), sa.PrimaryKeyConstraint('id', name=op.f('pk_playlist')))
    with op.batch_alter_table('playlist', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_playlist_author_id'), [
            'author_id'], unique=False)
    op.create_table('clip', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('link', sa.String(length=128), nullable=False), sa.Column
        ('name', sa.String(length=128), nullable=False), sa.Column(
        'author_id', sa.Integer(), nullable=True), sa.Column('playlist_id',
        sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['author_id'],
        ['user.id'], name=op.f('fk_clip_author_id_user'), ondelete=
        'CASCADE'), sa.ForeignKeyConstraint(['playlist_id'], ['playlist.id'
        ], name=op.f('fk_clip_playlist_id_playlist'), ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id', name=op.f('pk_clip')))
    with op.batch_alter_table('clip', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_clip_author_id'), ['author_id'
            ], unique=False)
        batch_op.create_index(batch_op.f('ix_clip_link'), ['link'], unique=True
            )
        batch_op.create_index(batch_op.f('ix_clip_playlist_id'), [
            'playlist_id'], unique=False)
    op.create_table('favorite', sa.Column('id', sa.Integer(), nullable=
        False), sa.Column('user_id', sa.Integer(), nullable=True), sa.
        Column('playlist_id', sa.Integer(), nullable=True), sa.
        ForeignKeyConstraint(['playlist_id'], ['playlist.id'], name=op.f(
        'fk_favorite_playlist_id_playlist'), ondelete='CASCADE'), sa.
        ForeignKeyConstraint(['user_id'], ['user.id'], name=op.f(
        'fk_favorite_user_id_user'), ondelete='CASCADE'), sa.
        PrimaryKeyConstraint('id', name=op.f('pk_favorite')))
    with op.batch_alter_table('favorite', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_favorite_playlist_id'), [
            'playlist_id'], unique=False)
        batch_op.create_index(batch_op.f('ix_favorite_user_id'), ['user_id'
            ], unique=False)


def downgrade():
    with op.batch_alter_table('favorite', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_favorite_user_id'))
        batch_op.drop_index(batch_op.f('ix_favorite_playlist_id'))
    op.drop_table('favorite')
    with op.batch_alter_table('clip', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_clip_playlist_id'))
        batch_op.drop_index(batch_op.f('ix_clip_link'))
        batch_op.drop_index(batch_op.f('ix_clip_author_id'))
    op.drop_table('clip')
    with op.batch_alter_table('playlist', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_playlist_author_id'))
    op.drop_table('playlist')

<mask token>
revision = '50de163bd2ec'
down_revision = 'f2856ed33727'
branch_labels = None
depends_on = None


def upgrade():
    op.create_table('playlist', sa.Column('id', sa.Integer(), nullable=
        False), sa.Column('name', sa.String(length=128), nullable=False),
        sa.Column('comment', sa.Text(), nullable=True), sa.Column(
        'author_id', sa.Integer(), nullable=True), sa.Column('is_public',
        sa.Boolean(), nullable=True), sa.ForeignKeyConstraint(['author_id'],
        ['user.id'], name=op.f('fk_playlist_author_id_user'), ondelete=
        'CASCADE'), sa.PrimaryKeyConstraint('id', name=op.f('pk_playlist')))
    with op.batch_alter_table('playlist', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_playlist_author_id'), [
            'author_id'], unique=False)
    op.create_table('clip', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('link', sa.String(length=128), nullable=False), sa.Column
        ('name', sa.String(length=128), nullable=False), sa.Column(
        'author_id', sa.Integer(), nullable=True), sa.Column('playlist_id',
        sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['author_id'],
        ['user.id'], name=op.f('fk_clip_author_id_user'), ondelete=
        'CASCADE'), sa.ForeignKeyConstraint(['playlist_id'], ['playlist.id'
        ], name=op.f('fk_clip_playlist_id_playlist'), ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id', name=op.f('pk_clip')))
    with op.batch_alter_table('clip', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_clip_author_id'), ['author_id'
            ], unique=False)
        batch_op.create_index(batch_op.f('ix_clip_link'), ['link'], unique=True
            )
        batch_op.create_index(batch_op.f('ix_clip_playlist_id'), [
            'playlist_id'], unique=False)
    op.create_table('favorite', sa.Column('id', sa.Integer(), nullable=
        False), sa.Column('user_id', sa.Integer(), nullable=True), sa.
        Column('playlist_id', sa.Integer(), nullable=True), sa.
        ForeignKeyConstraint(['playlist_id'], ['playlist.id'], name=op.f(
        'fk_favorite_playlist_id_playlist'), ondelete='CASCADE'), sa.
        ForeignKeyConstraint(['user_id'], ['user.id'], name=op.f(
        'fk_favorite_user_id_user'), ondelete='CASCADE'), sa.
        PrimaryKeyConstraint('id', name=op.f('pk_favorite')))
    with op.batch_alter_table('favorite', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_favorite_playlist_id'), [
            'playlist_id'], unique=False)
        batch_op.create_index(batch_op.f('ix_favorite_user_id'), ['user_id'
            ], unique=False)


def downgrade():
    with op.batch_alter_table('favorite', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_favorite_user_id'))
        batch_op.drop_index(batch_op.f('ix_favorite_playlist_id'))
    op.drop_table('favorite')
    with op.batch_alter_table('clip', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_clip_playlist_id'))
        batch_op.drop_index(batch_op.f('ix_clip_link'))
        batch_op.drop_index(batch_op.f('ix_clip_author_id'))
    op.drop_table('clip')
    with op.batch_alter_table('playlist', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_playlist_author_id'))
    op.drop_table('playlist')

<mask token>
from alembic import op
import sqlalchemy as sa
revision = '50de163bd2ec'
down_revision = 'f2856ed33727'
branch_labels = None
depends_on = None


def upgrade():
    op.create_table('playlist', sa.Column('id', sa.Integer(), nullable=
        False), sa.Column('name', sa.String(length=128), nullable=False),
        sa.Column('comment', sa.Text(), nullable=True), sa.Column(
        'author_id', sa.Integer(), nullable=True), sa.Column('is_public',
        sa.Boolean(), nullable=True), sa.ForeignKeyConstraint(['author_id'],
        ['user.id'], name=op.f('fk_playlist_author_id_user'), ondelete=
        'CASCADE'), sa.PrimaryKeyConstraint('id', name=op.f('pk_playlist')))
    with op.batch_alter_table('playlist', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_playlist_author_id'), [
            'author_id'], unique=False)
    op.create_table('clip', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('link', sa.String(length=128), nullable=False), sa.Column
        ('name', sa.String(length=128), nullable=False), sa.Column(
        'author_id', sa.Integer(), nullable=True), sa.Column('playlist_id',
        sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['author_id'],
        ['user.id'], name=op.f('fk_clip_author_id_user'), ondelete=
        'CASCADE'), sa.ForeignKeyConstraint(['playlist_id'], ['playlist.id'
        ], name=op.f('fk_clip_playlist_id_playlist'), ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id', name=op.f('pk_clip')))
    with op.batch_alter_table('clip', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_clip_author_id'), ['author_id'
            ], unique=False)
        batch_op.create_index(batch_op.f('ix_clip_link'), ['link'], unique=True
            )
        batch_op.create_index(batch_op.f('ix_clip_playlist_id'), [
            'playlist_id'], unique=False)
    op.create_table('favorite', sa.Column('id', sa.Integer(), nullable=
        False), sa.Column('user_id', sa.Integer(), nullable=True), sa.
        Column('playlist_id', sa.Integer(), nullable=True), sa.
        ForeignKeyConstraint(['playlist_id'], ['playlist.id'], name=op.f(
        'fk_favorite_playlist_id_playlist'), ondelete='CASCADE'), sa.
        ForeignKeyConstraint(['user_id'], ['user.id'], name=op.f(
        'fk_favorite_user_id_user'), ondelete='CASCADE'), sa.
        PrimaryKeyConstraint('id', name=op.f('pk_favorite')))
    with op.batch_alter_table('favorite', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_favorite_playlist_id'), [
            'playlist_id'], unique=False)
        batch_op.create_index(batch_op.f('ix_favorite_user_id'), ['user_id'
            ], unique=False)


def downgrade():
    with op.batch_alter_table('favorite', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_favorite_user_id'))
        batch_op.drop_index(batch_op.f('ix_favorite_playlist_id'))
    op.drop_table('favorite')
    with op.batch_alter_table('clip', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_clip_playlist_id'))
        batch_op.drop_index(batch_op.f('ix_clip_link'))
        batch_op.drop_index(batch_op.f('ix_clip_author_id'))
    op.drop_table('clip')
    with op.batch_alter_table('playlist', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_playlist_author_id'))
    op.drop_table('playlist')

"""add clip, playlist and favorite

Revision ID: 50de163bd2ec
Revises: f2856ed33727
Create Date: 2021-07-15 23:19:52.819596

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '50de163bd2ec'
down_revision = 'f2856ed33727'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('playlist',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=128), nullable=False),
    sa.Column('comment', sa.Text(), nullable=True),
    sa.Column('author_id', sa.Integer(), nullable=True),
    sa.Column('is_public', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['user.id'], name=op.f('fk_playlist_author_id_user'), ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_playlist'))
    )
    with op.batch_alter_table('playlist', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_playlist_author_id'), ['author_id'], unique=False)

    op.create_table('clip',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('link', sa.String(length=128), nullable=False),
    sa.Column('name', sa.String(length=128), nullable=False),
    sa.Column('author_id', sa.Integer(), nullable=True),
    sa.Column('playlist_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['user.id'], name=op.f('fk_clip_author_id_user'), ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['playlist_id'], ['playlist.id'], name=op.f('fk_clip_playlist_id_playlist'), ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_clip'))
    )
    with op.batch_alter_table('clip', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_clip_author_id'), ['author_id'], unique=False)
        batch_op.create_index(batch_op.f('ix_clip_link'), ['link'], unique=True)
        batch_op.create_index(batch_op.f('ix_clip_playlist_id'), ['playlist_id'], unique=False)

    op.create_table('favorite',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('playlist_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['playlist_id'], ['playlist.id'], name=op.f('fk_favorite_playlist_id_playlist'), ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], name=op.f('fk_favorite_user_id_user'), ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_favorite'))
    )
    with op.batch_alter_table('favorite', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_favorite_playlist_id'), ['playlist_id'], unique=False)
        batch_op.create_index(batch_op.f('ix_favorite_user_id'), ['user_id'], unique=False)

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('favorite', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_favorite_user_id'))
        batch_op.drop_index(batch_op.f('ix_favorite_playlist_id'))

    op.drop_table('favorite')
    with op.batch_alter_table('clip', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_clip_playlist_id'))
        batch_op.drop_index(batch_op.f('ix_clip_link'))
        batch_op.drop_index(batch_op.f('ix_clip_author_id'))

    op.drop_table('clip')
    with op.batch_alter_table('playlist', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_playlist_author_id'))

    op.drop_table('playlist')
    # ### end Alembic commands ###
