-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Migrate🛠️] View count to recipe model
- Loading branch information
[esekyi]
committed
Aug 30, 2024
1 parent
c0ced64
commit 13e7523
Showing
2 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
migrations/versions/66c940b91d74_added_direction_models_and_some_fixes_.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
32
migrations/versions/86043ab96515_add_view_count_to_recipe.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ### |