diff --git a/src/database/models/Book.py b/src/database/models/Book.py index db587ee4aa6b8c8c34fc7d70e2a159656668d0ba..91de2c299f5bb7ea654ae06dc21dbd64e9831d8b 100644 --- a/src/database/models/Book.py +++ b/src/database/models/Book.py @@ -9,7 +9,7 @@ Base = declarative_base() class Book(Base, Model): __tablename__ = 'books' id = Column(Integer, primary_key=True) - url = Column(String(255)) + url = Column(String(255), index=True, nullable=False) title = Column(String(255), nullable=False, index=True) description = Column(Text) @@ -18,9 +18,9 @@ class Book(Base, Model): upc = Column(String(32), unique=True) product_type = Column(String(32), index=True) - price_excl_tax = Column(Numeric(6, 2), index=True) - price_incl_tax = Column(Numeric(6, 2), index=True) - tax = Column(Numeric(6, 2), index=True) + price_excl_tax = Column(Numeric(6, 2)) + price_incl_tax = Column(Numeric(6, 2)) + tax = Column(Numeric(6, 2)) in_stock = Column(Integer, index=True) count_reviews = Column(Integer, index=True) diff --git a/src/database/versions/e19a8f6d44a2_create_books_table.py b/src/database/versions/08bb7bfd9fd6_create_books_table.py similarity index 81% rename from src/database/versions/e19a8f6d44a2_create_books_table.py rename to src/database/versions/08bb7bfd9fd6_create_books_table.py index 9e02b82560b6ff7d01c22fa663661c2ef54e972c..950079e3d5f585f9091a1be0ce7622a80bcb1a82 100644 --- a/src/database/versions/e19a8f6d44a2_create_books_table.py +++ b/src/database/versions/08bb7bfd9fd6_create_books_table.py @@ -1,8 +1,8 @@ """create books table -Revision ID: e19a8f6d44a2 +Revision ID: 08bb7bfd9fd6 Revises: -Create Date: 2019-06-17 13:21:39.815414 +Create Date: 2019-06-17 14:24:34.157665 """ from alembic import op @@ -10,7 +10,7 @@ import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = 'e19a8f6d44a2' +revision = '08bb7bfd9fd6' down_revision = None branch_labels = None depends_on = None @@ -20,7 +20,7 @@ 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('url', sa.String(length=255), nullable=False), 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), @@ -43,23 +43,19 @@ def upgrade(): 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) + op.create_index(op.f('ix_books_url'), 'books', ['url'], unique=False) # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### + op.drop_index(op.f('ix_books_url'), table_name='books') 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')