Skip to content
Snippets Groups Projects
Commit dc6c13b4 authored by Anton Gusev's avatar Anton Gusev
Browse files

add field created_at, updated_at to books table

parent c2ed3f1a
No related branches found
No related tags found
2 merge requests!5Develop,!4Develop
from sqlalchemy import Column, Integer, String, Text, SmallInteger, Numeric
from sqlalchemy import Column, Integer, String, Text, SmallInteger, Numeric, DateTime
from sqlalchemy.ext.declarative import declarative_base
from .Model import Model
from datetime import datetime
Base = declarative_base()
......@@ -26,3 +27,6 @@ class Book(Base, Model):
category = Column(String(32), index=True)
currency_type = Column(String(4), index=True)
created_at = Column(DateTime, default=datetime.utcnow)
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
"""create books table
Revision ID: 3217c19ef3a6
Revision ID: e19a8f6d44a2
Revises:
Create Date: 2019-06-13 18:27:06.732796
Create Date: 2019-06-17 13:21:39.815414
"""
from alembic import op
......@@ -10,7 +10,7 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '3217c19ef3a6'
revision = 'e19a8f6d44a2'
down_revision = None
branch_labels = None
depends_on = None
......@@ -34,6 +34,8 @@ def upgrade():
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.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('updated_at', sa.DateTime(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('upc')
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment