Spaces:
Sleeping
Sleeping
Download migrations/migrate_labinfo_fields.py from alisaleem97/NexLab_System: direct link, hf CLI and curl.
- Browser
- Download file 1.14 kB
-
https://huggingface.co/spaces/alisaleem97/NexLab_System/resolve/main/migrations/migrate_labinfo_fields.py
- Command line
-
hf download hf://spaces/alisaleem97/NexLab_System/migrations/migrate_labinfo_fields.py
-
curl -L -o migrate_labinfo_fields.py https://huggingface.co/spaces/alisaleem97/NexLab_System/resolve/main/migrations/migrate_labinfo_fields.py
1.14 kB
| import sqlite3 | |
| def migrate(): | |
| conn = sqlite3.connect("lab_database.db") | |
| cursor = conn.cursor() | |
| # Check if column already exists | |
| cursor.execute("PRAGMA table_info(labinfo)") | |
| columns = [col[1] for col in cursor.fetchall()] | |
| if "welcome_message" not in columns: | |
| cursor.execute("ALTER TABLE labinfo ADD COLUMN welcome_message TEXT DEFAULT NULL") | |
| print("Added welcome_message column to labinfo table") | |
| else: | |
| print("welcome_message column already exists") | |
| if "province_id" not in columns: | |
| cursor.execute("ALTER TABLE labinfo ADD COLUMN province_id INTEGER DEFAULT NULL") | |
| print("Added province_id column to labinfo table") | |
| else: | |
| print("province_id column already exists") | |
| if "welcome_template_name" not in columns: | |
| cursor.execute("ALTER TABLE labinfo ADD COLUMN welcome_template_name TEXT DEFAULT NULL") | |
| print("Added welcome_template_name column to labinfo table") | |
| else: | |
| print("welcome_template_name column already exists") | |
| conn.commit() | |
| conn.close() | |
| if __name__ == "__main__": | |
| migrate() | |