Skip to content

Commit

Permalink
add migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
FireFading committed Apr 14, 2023
1 parent e77c975 commit 08b857e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
- connect to postgres: `docker exec -it postgres psql -U postgres`

## migrations
- run docker containers by commands in "run project" section
- connect to docker container: `docker exec -it fastapi bash`
- apply migrations: `alembic upgrade head` in fastapi container
- create new migrations: `alembic revision --autogenerate -m "<migration name>"` in fastapi container
Expand Down
30 changes: 30 additions & 0 deletions migrations/versions/2023_04_14_1327-d88b1bbac7bc_orders.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""orders
Revision ID: d88b1bbac7bc
Revises: 36994ca6d50b
Create Date: 2023-04-14 13:27:34.953473
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'd88b1bbac7bc'
down_revision = '36994ca6d50b'
branch_labels = None
depends_on = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('products', sa.Column('avg_rating', sa.Float(), nullable=True))
op.add_column('products', sa.Column('reviews_count', sa.Integer(), nullable=True))
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('products', 'reviews_count')
op.drop_column('products', 'avg_rating')
# ### end Alembic commands ###

0 comments on commit 08b857e

Please sign in to comment.