Files
aitbc/apps/coordinator-api/migrations
oib ff4554b9dd ```
chore: remove obsolete payment architecture and integration test documentation

- Remove AITBC_PAYMENT_ARCHITECTURE.md (dual-currency system documentation)
- Remove IMPLEMENTATION_COMPLETE_SUMMARY.md (integration test completion summary)
- Remove INTEGRATION_TEST_FIXES.md (test fixes documentation)
- Remove INTEGRATION_TEST_UPDATES.md (real features implementation notes)
- Remove PAYMENT_INTEGRATION_COMPLETE.md (wallet-coordinator integration docs)
- Remove WALLET_COORDINATOR_INTEGRATION.md (payment
2026-01-29 12:28:43 +01:00
..
```
2026-01-24 18:34:37 +01:00
```
2026-01-24 18:34:37 +01:00
```
2026-01-24 18:34:37 +01:00
```
2026-01-29 12:28:43 +01:00
```
2026-01-24 18:34:37 +01:00

Coordinator API Migrations

Database migration scripts for the Coordinator API.

Files

File Description
001_initial_schema.sql Initial database schema (tables)
002_indexes.sql Performance indexes
003_data_migration.py Data migration utilities

Running Migrations

Prerequisites

  • PostgreSQL 14+
  • Python 3.10+ (for data migrations)
  • asyncpg package

Apply Schema

# Connect to database
psql -h localhost -U aitbc -d coordinator

# Run migrations in order
\i 001_initial_schema.sql
\i 002_indexes.sql

Run Data Migrations

# Install dependencies
pip install asyncpg

# Backfill job history
python 003_data_migration.py --action=backfill_history

# Update miner statistics
python 003_data_migration.py --action=update_stats

# Run all maintenance tasks
python 003_data_migration.py --action=all

# Migrate from SQLite
python 003_data_migration.py --action=migrate_jobs --input-file=/path/to/jobs.db

# Migrate receipts from JSON
python 003_data_migration.py --action=migrate_receipts --input-file=/path/to/receipts.json

Schema Overview

Tables

  • jobs - AI compute jobs
  • miners - Registered GPU miners
  • receipts - Cryptographic receipts
  • blocks - Blockchain blocks
  • transactions - On-chain transactions
  • api_keys - API authentication
  • job_history - Event history for analytics

Key Indexes

  • idx_jobs_pending - Fast pending job lookup
  • idx_miners_available - Available miner selection
  • idx_receipts_provider_created - Miner receipt history
  • idx_receipts_client_created - Client receipt history

Rollback

To rollback migrations:

-- Drop all tables (DESTRUCTIVE)
DROP TABLE IF EXISTS job_history CASCADE;
DROP TABLE IF EXISTS api_keys CASCADE;
DROP TABLE IF EXISTS transactions CASCADE;
DROP TABLE IF EXISTS blocks CASCADE;
DROP TABLE IF EXISTS receipts CASCADE;
DROP TABLE IF EXISTS miners CASCADE;
DROP TABLE IF EXISTS jobs CASCADE;