Rename modified column to updated

This commit is contained in:
coolneng 2020-07-22 23:58:56 +02:00
parent b1f1ffd0e2
commit 6787237c7e
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
3 changed files with 48 additions and 11 deletions

View File

@ -71,7 +71,7 @@ class Cities(Base):
image = Column(String(255))
status = Column(Enum("1", "0"))
created = Column(DateTime, nullable=False, server_default=func.now())
modified = Column(DateTime, nullable=True, onupdate=func.now())
updated = Column(DateTime, nullable=True, onupdate=func.now())
def __init__(self, name, image, status):
self.name = name
@ -106,7 +106,7 @@ class Games(Base):
noti_status = Column(Integer, server_default=text("0"))
conduct_status = Column(Integer, server_default=text("1"))
created = Column(DateTime, nullable=False, server_default=func.now())
modified = Column(DateTime, nullable=True, onupdate=func.now())
updated = Column(DateTime, nullable=True, onupdate=func.now())
def __init__(
self,
@ -159,7 +159,7 @@ class Payments(Base):
pay_mode = Column(Integer)
status = Column(Integer)
created = Column(DateTime, nullable=False, server_default=func.now())
modified = Column(DateTime, nullable=True, onupdate=func.now())
updated = Column(DateTime, nullable=True, onupdate=func.now())
def __init__(
self,
@ -196,7 +196,7 @@ class PlayerAvailabilities(Base):
player_id = Column(Integer)
status = Column(Integer)
created = Column(DateTime, nullable=False, server_default=func.now())
modified = Column(DateTime, nullable=True, onupdate=func.now())
updated = Column(DateTime, nullable=True, onupdate=func.now())
def __init__(
self, game_id, player_id, status,
@ -213,7 +213,7 @@ class PlayerCancelGames(Base):
player_id = Column(Integer)
game_id = Column(Integer)
created = Column(DateTime, nullable=False, server_default=func.now())
modified = Column(DateTime, nullable=True, onupdate=func.now())
updated = Column(DateTime, nullable=True, onupdate=func.now())
def __init__(
self, player_id, game_id,
@ -230,7 +230,7 @@ class PurchaseGames(Base):
user_id = Column(Integer)
pay_mode = Column(Integer)
created = Column(DateTime, nullable=False, server_default=func.now())
modified = Column(DateTime, nullable=True, onupdate=func.now())
updated = Column(DateTime, nullable=True, onupdate=func.now())
def __init__(
self, game_id, user_id, pay_mode,
@ -248,7 +248,7 @@ class Sports(Base):
spanish_name = Column(String(100))
status = Column(Integer)
created = Column(DateTime, nullable=False, server_default=func.now())
modified = Column(DateTime, nullable=True, onupdate=func.now())
updated = Column(DateTime, nullable=True, onupdate=func.now())
def __init__(
self, name, spanish_name, status,
@ -267,7 +267,7 @@ class Teams(Base):
game_id = Column(Integer)
status = Column(Integer)
created = Column(DateTime, nullable=False, server_default=func.now())
modified = Column(DateTime, nullable=True, onupdate=func.now())
updated = Column(DateTime, nullable=True, onupdate=func.now())
def __init__(
self, game_id, user_id, team_id, status,
@ -287,7 +287,7 @@ class UserRatings(Base):
player_id = Column(Integer)
rating = Column(String(100))
created = Column(DateTime, nullable=False, server_default=func.now())
modified = Column(DateTime, nullable=True, onupdate=func.now())
updated = Column(DateTime, nullable=True, onupdate=func.now())
user_type = Column(Integer)
def __init__(self, game_id, user_id, player_id, rating, user_type):
@ -327,7 +327,7 @@ class Venues(Base):
name = Column(String(100))
sports_id = Column(Integer)
created = Column(DateTime, nullable=False, server_default=func.now())
modified = Column(DateTime, nullable=True, onupdate=func.now())
updated = Column(DateTime, nullable=True, onupdate=func.now())
def __init__(
self, user_id, address, latitude, longitude, name, sports_id,

View File

@ -0,0 +1,38 @@
"""rename modified to updated
Revision ID: 05f3ae5db7c7
Revises: 970563653ece
Create Date: 2020-07-22 23:56:38.694837
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "05f3ae5db7c7"
down_revision = "970563653ece"
branch_labels = None
depends_on = None
def upgrade():
tables = {
"cities": "modified",
"games": "modified",
"payments": "modified",
"player_availabilities": "modified",
"player_cancel_games": "modified",
"purchase_games": "modified",
"sports": "modified",
"teams": "modified",
"user_ratings": "modified",
"venues": "modified",
}
for table, field in tables.items():
with op.batch_alter_table(table) as batch_op:
batch_op.alter_column(column_name=field, new_column_name="updated")
def downgrade():
pass

View File

@ -20,7 +20,6 @@ def upgrade():
tables = {
"cities": "updated",
"games": "updated",
"games": "cancel_date",
"payments": "updated",
"player_availabilities": "updated",
"player_cancel_games": "updated",