-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_description_field.py
More file actions
29 lines (24 loc) · 1.01 KB
/
add_description_field.py
File metadata and controls
29 lines (24 loc) · 1.01 KB
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
import sys
import os
# Set the application directory to the current directory
sys.path.insert(0, os.path.abspath('.'))
from app import app, db
from sqlalchemy import Column, Text, text
def add_description_column():
"""Add description column to the tradeline table"""
with app.app_context():
# Add description column using db session execute
engine = db.engine
inspector = db.inspect(engine)
# Check if the column already exists
columns = [col['name'] for col in inspector.get_columns('tradeline')]
if 'description' not in columns:
print("Adding description column to tradeline table...")
with engine.connect() as conn:
conn.execute(text('ALTER TABLE tradeline ADD COLUMN description TEXT'))
conn.commit()
print("Description column added successfully.")
else:
print("Description column already exists in tradeline table.")
if __name__ == "__main__":
add_description_column()