Skip to content

Commit

Permalink
[Migrate🛠️] View count to recipe model
Browse files Browse the repository at this point in the history
  • Loading branch information
[esekyi] committed Aug 30, 2024
1 parent c0ced64 commit 13e7523
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""added direction models and some fixes in column
Revision ID: 66c940b91d74
Revises: 4aa0dd9e6402
Create Date: 2024-08-28 05:03:41.750877
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '66c940b91d74'
down_revision = '4aa0dd9e6402'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('instruction',
sa.Column('id', sa.UUID(), nullable=False),
sa.Column('step_number', sa.Integer(), nullable=False),
sa.Column('name', sa.Text(), nullable=False),
sa.Column('recipe_id', sa.UUID(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('updated_at', sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(['recipe_id'], ['recipe.id'], ),
sa.PrimaryKeyConstraint('id')
)
with op.batch_alter_table('ingredient', schema=None) as batch_op:
batch_op.drop_column('quantity')

with op.batch_alter_table('recipe', schema=None) as batch_op:
batch_op.add_column(sa.Column('oven_temp', sa.Integer(), nullable=True))
batch_op.drop_column('instructions')

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('recipe', schema=None) as batch_op:
batch_op.add_column(sa.Column('instructions', sa.TEXT(), autoincrement=False, nullable=False))
batch_op.drop_column('oven_temp')

with op.batch_alter_table('ingredient', schema=None) as batch_op:
batch_op.add_column(sa.Column('quantity', sa.VARCHAR(length=50), autoincrement=False, nullable=False))

op.drop_table('instruction')
# ### end Alembic commands ###
32 changes: 32 additions & 0 deletions migrations/versions/86043ab96515_add_view_count_to_recipe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""Add view_count to Recipe
Revision ID: 86043ab96515
Revises: 66c940b91d74
Create Date: 2024-08-30 02:07:28.442024
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '86043ab96515'
down_revision = '66c940b91d74'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('recipe', schema=None) as batch_op:
batch_op.add_column(sa.Column('view_count', sa.Integer(), nullable=True))

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('recipe', schema=None) as batch_op:
batch_op.drop_column('view_count')

# ### end Alembic commands ###

0 comments on commit 13e7523

Please sign in to comment.