Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"""create books table
Revision ID: 3217c19ef3a6
Revises:
Create Date: 2019-06-13 18:27:06.732796
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '3217c19ef3a6'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('books',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('url', sa.String(length=255), nullable=True),
sa.Column('title', sa.String(length=255), nullable=False),
sa.Column('description', sa.Text(), nullable=True),
sa.Column('image_path', sa.String(length=255), nullable=True),
sa.Column('rating', sa.SmallInteger(), nullable=True),
sa.Column('upc', sa.String(length=32), nullable=True),
sa.Column('product_type', sa.String(length=32), nullable=True),
sa.Column('price_excl_tax', sa.Numeric(precision=6, scale=2), nullable=True),
sa.Column('price_incl_tax', sa.Numeric(precision=6, scale=2), nullable=True),
sa.Column('tax', sa.Numeric(precision=6, scale=2), nullable=True),
sa.Column('in_stock', sa.Integer(), nullable=True),
sa.Column('count_reviews', sa.Integer(), nullable=True),
sa.Column('category', sa.String(length=32), nullable=True),
sa.Column('currency_type', sa.String(length=4), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('upc')
)
op.create_index(op.f('ix_books_category'), 'books', ['category'], unique=False)
op.create_index(op.f('ix_books_count_reviews'), 'books', ['count_reviews'], unique=False)
op.create_index(op.f('ix_books_currency_type'), 'books', ['currency_type'], unique=False)
op.create_index(op.f('ix_books_in_stock'), 'books', ['in_stock'], unique=False)
op.create_index(op.f('ix_books_price_excl_tax'), 'books', ['price_excl_tax'], unique=False)
op.create_index(op.f('ix_books_price_incl_tax'), 'books', ['price_incl_tax'], unique=False)
op.create_index(op.f('ix_books_product_type'), 'books', ['product_type'], unique=False)
op.create_index(op.f('ix_books_rating'), 'books', ['rating'], unique=False)
op.create_index(op.f('ix_books_tax'), 'books', ['tax'], unique=False)
op.create_index(op.f('ix_books_title'), 'books', ['title'], unique=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_books_title'), table_name='books')
op.drop_index(op.f('ix_books_tax'), table_name='books')
op.drop_index(op.f('ix_books_rating'), table_name='books')
op.drop_index(op.f('ix_books_product_type'), table_name='books')
op.drop_index(op.f('ix_books_price_incl_tax'), table_name='books')
op.drop_index(op.f('ix_books_price_excl_tax'), table_name='books')
op.drop_index(op.f('ix_books_in_stock'), table_name='books')
op.drop_index(op.f('ix_books_currency_type'), table_name='books')
op.drop_index(op.f('ix_books_count_reviews'), table_name='books')
op.drop_index(op.f('ix_books_category'), table_name='books')
op.drop_table('books')
# ### end Alembic commands ###