Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 2,182 Bytes
5582677 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
#!/usr/bin/env python3
"""
Migration script to add coordinated voting campaign detection and user timeout tables.
Run this script to add the new tables to your existing database.
"""
import os
import sys
from datetime import datetime
# Add the current directory to the Python path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from app import app
from models import db, CoordinatedVotingCampaign, CampaignParticipant, UserTimeout
def migrate_database():
"""Add the new tables to the database"""
with app.app_context():
try:
print("Creating new tables for coordinated voting detection and user timeouts...")
# Create the new tables
db.create_all()
print("β
Successfully created new tables:")
print(" - coordinated_voting_campaign")
print(" - campaign_participant")
print(" - user_timeout")
print("\nMigration completed successfully!")
return True
except Exception as e:
print(f"β Error during migration: {str(e)}")
return False
if __name__ == "__main__":
print("TTS Arena - Database Migration for Timeout and Campaign Management")
print("=" * 70)
# Confirm with user
response = input("This will add new tables to your database. Continue? (y/N): ")
if response.lower() != 'y':
print("Migration cancelled.")
sys.exit(0)
success = migrate_database()
if success:
print("\n" + "=" * 70)
print("Migration completed! You can now:")
print("1. Access the new admin panels for timeout and campaign management")
print("2. Automatic coordinated voting detection is now active")
print("3. Users involved in coordinated campaigns will be automatically timed out")
print("\nNew admin panel sections:")
print("- /admin/timeouts - Manage user timeouts")
print("- /admin/campaigns - View and manage coordinated voting campaigns")
else:
print("\nβ Migration failed. Please check the error messages above.")
sys.exit(1) |