45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
"""add views
|
|
|
|
Revision ID: f79ee0125ba6
|
|
Revises: 60e8f49dee49
|
|
Create Date: 2022-02-07 13:29:26.663482
|
|
|
|
"""
|
|
import sqlalchemy as sa
|
|
from app import db
|
|
from app.models import query_price_per_amount_view, query_bought_with_prices_view
|
|
from alembic import op
|
|
from sqlalchemy_utils import create_view
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = 'f79ee0125ba6'
|
|
down_revision = '60e8f49dee49'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
metadata = sa.MetaData()
|
|
create_view('price_per_amount',
|
|
query_price_per_amount_view(),
|
|
metadata
|
|
)
|
|
create_view('bought_with_prices',
|
|
query_bought_with_prices_view(),
|
|
metadata
|
|
)
|
|
metadata.create_all(db.engine)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
with db.engine.connect() as con:
|
|
con.execute("DROP VIEW bought_with_prices;")
|
|
con.execute("DROP VIEW price_per_amount;")
|
|
#op.drop_table('bought_with_prices')
|
|
#op.drop_table('price_per_amount')
|
|
# ### end Alembic commands ###
|