Commit 0052431f authored by Your Name's avatar Your Name

feat(payments): add database schema and migrations

parent 56fac49b
...@@ -144,6 +144,13 @@ class DatabaseManager: ...@@ -144,6 +144,13 @@ class DatabaseManager:
conn.commit() conn.commit()
logger.debug(f"Recorded context dimension for {provider_id}/{model_name}") logger.debug(f"Recorded context dimension for {provider_id}/{model_name}")
def run_payment_migrations(self):
"""Run payment system migrations"""
from aisbf.payments.migrations import PaymentMigrations
migrations = PaymentMigrations(self)
migrations.run_migrations()
def get_context_dimension( def get_context_dimension(
self, self,
provider_id: str, provider_id: str,
......
"""
Payment system module
"""
from aisbf.payments.migrations import PaymentMigrations
__all__ = ['PaymentMigrations']
This diff is collapsed.
"""Payment system tests"""
import pytest
from aisbf.database import DatabaseManager
from aisbf.payments.migrations import PaymentMigrations
def test_migrations_create_all_tables(tmp_path):
"""Test that migrations create all required tables"""
db_path = tmp_path / "test.db"
db_config = {
'type': 'sqlite',
'sqlite_path': str(db_path)
}
db = DatabaseManager(db_config)
migrations = PaymentMigrations(db)
migrations.run_migrations()
# Check that key tables exist
with db._get_connection() as conn:
cursor = conn.cursor()
cursor.execute("""
SELECT name FROM sqlite_master
WHERE type='table'
""")
tables = cursor.fetchall()
table_names = [t[0] for t in tables]
assert 'crypto_master_keys' in table_names
assert 'user_crypto_addresses' in table_names
assert 'user_crypto_wallets' in table_names
assert 'crypto_transactions' in table_names
assert 'payment_retry_queue' in table_names
assert 'subscriptions' in table_names
assert 'job_locks' in table_names
assert 'crypto_price_sources' in table_names
assert 'email_notification_settings' in table_names
def test_migrations_insert_default_data(tmp_path):
"""Test that default data is inserted"""
db_path = tmp_path / "test.db"
db_config = {
'type': 'sqlite',
'sqlite_path': str(db_path)
}
db = DatabaseManager(db_config)
migrations = PaymentMigrations(db)
migrations.run_migrations()
# Check price sources
with db._get_connection() as conn:
cursor = conn.cursor()
cursor.execute("SELECT * FROM crypto_price_sources")
sources = cursor.fetchall()
assert len(sources) >= 3
# Check consolidation settings
cursor.execute("SELECT * FROM crypto_consolidation_settings")
settings = cursor.fetchall()
assert len(settings) == 4
# Check email notification settings
cursor.execute("SELECT * FROM email_notification_settings")
notifications = cursor.fetchall()
assert len(notifications) >= 9
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment