From 6787237c7ef5f8f8689fe188ec841618394b0282 Mon Sep 17 00:00:00 2001 From: coolneng Date: Wed, 22 Jul 2020 23:58:56 +0200 Subject: [PATCH] Rename modified column to updated --- database/models.py | 20 +++++----- ...05f3ae5db7c7_rename_modified_to_updated.py | 38 +++++++++++++++++++ ...653ece_set_modified_updated_as_nullable.py | 1 - 3 files changed, 48 insertions(+), 11 deletions(-) create mode 100644 migrations/versions/05f3ae5db7c7_rename_modified_to_updated.py diff --git a/database/models.py b/database/models.py index e0ed92a..6d8ca53 100644 --- a/database/models.py +++ b/database/models.py @@ -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, diff --git a/migrations/versions/05f3ae5db7c7_rename_modified_to_updated.py b/migrations/versions/05f3ae5db7c7_rename_modified_to_updated.py new file mode 100644 index 0000000..4e2e11f --- /dev/null +++ b/migrations/versions/05f3ae5db7c7_rename_modified_to_updated.py @@ -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 diff --git a/migrations/versions/970563653ece_set_modified_updated_as_nullable.py b/migrations/versions/970563653ece_set_modified_updated_as_nullable.py index 90b343e..f24f8d8 100644 --- a/migrations/versions/970563653ece_set_modified_updated_as_nullable.py +++ b/migrations/versions/970563653ece_set_modified_updated_as_nullable.py @@ -20,7 +20,6 @@ def upgrade(): tables = { "cities": "updated", "games": "updated", - "games": "cancel_date", "payments": "updated", "player_availabilities": "updated", "player_cancel_games": "updated",