-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmigrate_price_fields.py
More file actions
77 lines (67 loc) · 2.18 KB
/
migrate_price_fields.py
File metadata and controls
77 lines (67 loc) · 2.18 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
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env python3
"""
Add missing price fields using the bidirectional field system
"""
import sqlite3
from ui_field_config import UIFieldManager
def migrate_price_fields():
"""Add missing price fields to database"""
# Missing price fields that the UI expects
missing_fields = [
{
'id': 'price_usd',
'header': 'Price USD',
'db_field': 'price_usd',
'sortable': True,
'type': 'currency',
'display_format': 'price',
'width': '100px'
},
{
'id': 'price_change_5m',
'header': '5m Change',
'db_field': 'price_change_5m',
'sortable': True,
'type': 'percentage',
'display_format': 'price_change',
'width': '80px'
},
{
'id': 'price_change_24h',
'header': '24h Change',
'db_field': 'price_change_24h',
'sortable': True,
'type': 'percentage',
'display_format': 'price_change',
'width': '80px'
},
{
'id': 'last_price_update',
'header': 'Last Update',
'db_field': 'last_price_update',
'sortable': True,
'type': 'text',
'display_format': 'timestamp',
'width': '120px'
}
]
# Use the bidirectional field manager
manager = UIFieldManager()
print("🔄 Adding missing price fields to database...")
for field in missing_fields:
try:
manager._add_db_field(field)
except Exception as e:
print(f"⚠️ Error adding {field['db_field']}: {e}")
# Verify fields were added
conn = sqlite3.connect('raydium_pools.db')
cursor = conn.execute("PRAGMA table_info(pools)")
columns = [row[1] for row in cursor.fetchall()]
conn.close()
print("\n📊 Current price-related columns:")
price_columns = [col for col in columns if 'price' in col.lower() or 'change' in col.lower()]
for col in price_columns:
print(f" ✅ {col}")
print(f"\n🎉 Total columns in pools table: {len(columns)}")
if __name__ == "__main__":
migrate_price_fields()