-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_name_column.py
More file actions
36 lines (29 loc) · 1.07 KB
/
add_name_column.py
File metadata and controls
36 lines (29 loc) · 1.07 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
30
31
32
33
34
35
36
"""
Add name column to webhooks table
"""
import sqlite3
def add_name_column():
"""Add name column to existing webhooks table"""
try:
conn = sqlite3.connect('icc_rules.db')
cursor = conn.cursor()
# Check if name column already exists
cursor.execute("PRAGMA table_info(webhooks);")
columns = [row[1] for row in cursor.fetchall()]
if 'name' not in columns:
# Add the name column
cursor.execute("ALTER TABLE webhooks ADD COLUMN name TEXT;")
print("Added 'name' column to webhooks table")
# Update existing webhooks with default names
cursor.execute("UPDATE webhooks SET name = 'Webhook ' || id WHERE name IS NULL;")
print("Updated existing webhooks with default names")
else:
print("'name' column already exists in webhooks table")
conn.commit()
conn.close()
return True
except Exception as e:
print(f"Error adding name column: {e}")
return False
if __name__ == "__main__":
add_name_column()