diff --git a/migrations/versions/f6f0a537719a_added_subscribe_model.py b/migrations/versions/0f04b467b1a7_added_subscribe_model.py similarity index 66% rename from migrations/versions/f6f0a537719a_added_subscribe_model.py rename to migrations/versions/0f04b467b1a7_added_subscribe_model.py index 56f74de..fa8b31b 100644 --- a/migrations/versions/f6f0a537719a_added_subscribe_model.py +++ b/migrations/versions/0f04b467b1a7_added_subscribe_model.py @@ -1,8 +1,8 @@ """Added Subscribe model -Revision ID: f6f0a537719a -Revises: 86043ab96515 -Create Date: 2024-09-11 14:36:40.996536 +Revision ID: 0f04b467b1a7 +Revises: +Create Date: 2024-09-14 05:11:39.635188 """ from alembic import op @@ -10,8 +10,8 @@ # revision identifiers, used by Alembic. -revision = 'f6f0a537719a' -down_revision = '86043ab96515' +revision = '0f04b467b1a7' +down_revision = None branch_labels = None depends_on = None @@ -26,10 +26,16 @@ def upgrade(): sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('email') ) + 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') + op.drop_table('subscriber') # ### end Alembic commands ### diff --git a/migrations/versions/4aa0dd9e6402_changed_models_id_to_uuid_from_.py b/migrations/versions/4aa0dd9e6402_changed_models_id_to_uuid_from_.py deleted file mode 100644 index 1af4321..0000000 --- a/migrations/versions/4aa0dd9e6402_changed_models_id_to_uuid_from_.py +++ /dev/null @@ -1,97 +0,0 @@ -"""Changed models id to UUID from sqlalchemy dialects - -Revision ID: 4aa0dd9e6402 -Revises: -Create Date: 2024-08-25 05:54:27.114460 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '4aa0dd9e6402' -down_revision = None -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('category', - sa.Column('id', sa.UUID(), nullable=False), - sa.Column('name', sa.String(length=80), nullable=False), - sa.Column('description', sa.Text(), nullable=True), - sa.Column('created_at', sa.DateTime(), nullable=True), - sa.Column('updated_at', sa.DateTime(), nullable=True), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('name') - ) - op.create_table('user', - sa.Column('id', sa.UUID(), nullable=False), - sa.Column('first_name', sa.String(length=50), nullable=False), - sa.Column('last_name', sa.String(length=50), nullable=False), - sa.Column('username', sa.String(length=80), nullable=False), - sa.Column('email', sa.String(length=120), nullable=False), - sa.Column('password_hash', sa.String(length=255), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=True), - sa.Column('updated_at', sa.DateTime(), nullable=True), - sa.PrimaryKeyConstraint('id') - ) - with op.batch_alter_table('user', schema=None) as batch_op: - batch_op.create_index(batch_op.f('ix_user_email'), ['email'], unique=True) - batch_op.create_index(batch_op.f('ix_user_username'), ['username'], unique=True) - - op.create_table('recipe', - sa.Column('id', sa.UUID(), nullable=False), - sa.Column('title', sa.String(length=120), nullable=False), - sa.Column('description', sa.Text(), nullable=False), - sa.Column('instructions', sa.Text(), nullable=False), - sa.Column('prep_time', sa.Integer(), nullable=True), - sa.Column('cook_time', sa.Integer(), nullable=True), - sa.Column('servings', sa.Integer(), nullable=True), - sa.Column('image_url', sa.String(length=255), nullable=True), - sa.Column('category_id', sa.UUID(), nullable=False), - sa.Column('user_id', sa.UUID(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=True), - sa.Column('updated_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['category_id'], ['category.id'], ), - sa.ForeignKeyConstraint(['user_id'], ['user.id'], ), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('comment', - sa.Column('id', sa.UUID(), nullable=False), - sa.Column('text', sa.Text(), nullable=False), - sa.Column('user_id', sa.UUID(), 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.ForeignKeyConstraint(['user_id'], ['user.id'], ), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('ingredient', - sa.Column('id', sa.UUID(), nullable=False), - sa.Column('name', sa.String(length=120), nullable=False), - sa.Column('quantity', sa.String(length=50), 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') - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('ingredient') - op.drop_table('comment') - op.drop_table('recipe') - with op.batch_alter_table('user', schema=None) as batch_op: - batch_op.drop_index(batch_op.f('ix_user_username')) - batch_op.drop_index(batch_op.f('ix_user_email')) - - op.drop_table('user') - op.drop_table('category') - # ### end Alembic commands ### diff --git a/migrations/versions/5246baafeb00_added_subscribe_model.py b/migrations/versions/5246baafeb00_added_subscribe_model.py deleted file mode 100644 index 257c46b..0000000 --- a/migrations/versions/5246baafeb00_added_subscribe_model.py +++ /dev/null @@ -1,35 +0,0 @@ -"""Added Subscribe model - -Revision ID: 5246baafeb00 -Revises: f6f0a537719a -Create Date: 2024-09-11 16:35:24.804373 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '5246baafeb00' -down_revision = 'f6f0a537719a' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('subscriber', - sa.Column('id', sa.UUID(), nullable=False), - sa.Column('email', sa.String(length=120), nullable=False), - sa.Column('subscribed_on', sa.DateTime(), nullable=True), - sa.Column('is_active', sa.Boolean(), nullable=True), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('email') - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('subscriber') - # ### end Alembic commands ### diff --git a/migrations/versions/66c940b91d74_added_direction_models_and_some_fixes_.py b/migrations/versions/66c940b91d74_added_direction_models_and_some_fixes_.py deleted file mode 100644 index 38155ca..0000000 --- a/migrations/versions/66c940b91d74_added_direction_models_and_some_fixes_.py +++ /dev/null @@ -1,51 +0,0 @@ -"""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 ### diff --git a/migrations/versions/86043ab96515_add_view_count_to_recipe.py b/migrations/versions/86043ab96515_add_view_count_to_recipe.py deleted file mode 100644 index f2cf947..0000000 --- a/migrations/versions/86043ab96515_add_view_count_to_recipe.py +++ /dev/null @@ -1,32 +0,0 @@ -"""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 ###