"""update note tag

Revision ID: 07148db85539
Revises: f808ed002709
Create Date: 2022-05-22 17:39:16.120153

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '07148db85539'
down_revision = 'f808ed002709'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('association_note_tag',
    sa.Column('note_id', sa.Integer(), nullable=False),
    sa.Column('tag_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['note_id'], ['note.id'], ),
    sa.ForeignKeyConstraint(['tag_id'], ['tag.id'], ),
    sa.PrimaryKeyConstraint('note_id', 'tag_id')
    )
    op.drop_constraint('tag_note_id_fkey', 'tag', type_='foreignkey')
    op.drop_column('tag', 'note_id')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('tag', sa.Column('note_id', sa.INTEGER(), autoincrement=False, nullable=True))
    op.create_foreign_key('tag_note_id_fkey', 'tag', 'note', ['note_id'], ['id'])
    op.drop_table('association_note_tag')
    # ### end Alembic commands ###
