fix probleme avec dispos

This commit is contained in:
cedrick2711
2026-08-06 13:41:53 -04:00
parent d25b35c928
commit 68e3da6601
11 changed files with 582 additions and 246 deletions
+38
View File
@@ -0,0 +1,38 @@
"""Migration: Add end_date column to tryouts table.
Run this script to add the end_date column to the tryouts table.
Usage: python migrations/add_tryout_end_date.py
"""
import sys
import os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from app.app import create_app
from app.extensions import db
from sqlalchemy import text
app = create_app()
with app.app_context():
# Check if column already exists
result = db.session.execute(text(
"SELECT COUNT(*) FROM information_schema.columns "
"WHERE table_name = 'tryouts' AND column_name = 'end_date'"
))
exists = result.scalar() > 0
if exists:
print("Column 'end_date' already exists in 'tryouts' table. Skipping.")
else:
db.session.execute(text(
"ALTER TABLE tryouts ADD COLUMN end_date DATE NULL"
))
# Backfill: set end_date = date for existing tryouts
db.session.execute(text(
"UPDATE tryouts SET end_date = date WHERE end_date IS NULL"
))
db.session.commit()
print("Successfully added 'end_date' column to 'tryouts' table and backfilled existing rows.")
print("Migration complete.")