Upgraded to Timezone Aware Datetimes

deb
androiddrew 7 years ago
parent 4f4099d998
commit bd818f1cf2

@ -35,7 +35,7 @@ script_location = migrations
# are written from script.py.mako # are written from script.py.mako
# output_encoding = utf-8 # output_encoding = utf-8
sqlalchemy.url = driver://user:pass@localhost/dbname sqlalchemy.url = postgresql://apistar@localhost:5432/apistar
# Logging configuration # Logging configuration

@ -25,8 +25,8 @@ Base = declarative_base()
class DBMixin: class DBMixin:
id = Column(Integer, primary_key=True, autoincrement=True) id = Column(Integer, primary_key=True, autoincrement=True)
created_date = Column(DateTime, server_default=utcnow()) created_date = Column(DateTime(timezone=True), server_default=utcnow())
modified_date = Column(DateTime, server_default=utcnow(), onupdate=utcnow()) modified_date = Column(DateTime(timezone=True), server_default=utcnow(), onupdate=utcnow())
def to_dict(self): def to_dict(self):
d = self.__dict__.copy() d = self.__dict__.copy()

@ -0,0 +1,67 @@
"""Changed Datetimes to be UTC
Revision ID: 7eb9aabef1dc
Revises: 82595a1e5193
Create Date: 2018-05-07 13:59:32.923484
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '7eb9aabef1dc'
down_revision = '82595a1e5193'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column(
table_name='cookies',
column_name='created_date',
type_=sa.DateTime(timezone=True)
)
op.alter_column(
table_name='cookies',
column_name='modified_date',
type_=sa.DateTime(timezone=True)
)
op.alter_column(
table_name='users',
column_name='created_date',
type_=sa.DateTime(timezone=True)
)
op.alter_column(
table_name='users',
column_name='modified_date',
type_=sa.DateTime(timezone=True)
)
op.alter_column(
table_name='orders',
column_name='created_date',
type_=sa.DateTime(timezone=True)
)
op.alter_column(
table_name='orders',
column_name='modified_date',
type_=sa.DateTime(timezone=True)
)
op.alter_column(
table_name='line_items',
column_name='created_date',
type_=sa.DateTime(timezone=True)
)
op.alter_column(
table_name='line_items',
column_name='modified_date',
type_=sa.DateTime(timezone=True)
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
Loading…
Cancel
Save