46 lines
1.1 KiB
Python
46 lines
1.1 KiB
Python
"""make updated field nullable
|
|
|
|
Revision ID: eaa992d1469b
|
|
Revises:
|
|
Create Date: 2020-07-04 18:08:31.035209
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = "eaa992d1469b"
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
tables = {
|
|
"modified": "cities",
|
|
"modified": "games",
|
|
"cancel_date": "games",
|
|
"modified": "payments",
|
|
"modified": "player_availabilities",
|
|
"modified": "player_cancel_games",
|
|
"modified": "purchase_games",
|
|
"modified": "sports",
|
|
"modified": "teams",
|
|
"modified": "user_ratings",
|
|
"modified": "venues",
|
|
"updated": "venue_images",
|
|
"updated": "web_bookings",
|
|
}
|
|
for field, table in tables.items():
|
|
with op.batch_alter_table(table) as batch_op:
|
|
batch_op.alter_column(column_name=field, nullable=True)
|
|
query = "UPDATE {0} SET {1} = NULL WHERE {1} = '0000-00-00 00:00:00'".format(
|
|
table, field
|
|
)
|
|
op.execute(query)
|
|
|
|
|
|
def downgrade():
|
|
pass
|