Files
microdao-daarion/docs/tasks/APPLY_MIGRATIONS_INSTRUCTIONS.md
Apple fca48b3eb0 feat(node2): Complete NODE2 setup - guardian, agents, swapper models
- Node-guardian running on MacBook and updating metrics
- NODE2 agents (Atlas, Greeter, Oracle, Builder Bot) assigned to node-2-macbook-m4max
- Swapper models displaying correctly (8 models)
- DAGI Router agents showing with correct status (3 active, 1 stale)
- Router health check using node_cache for remote nodes
2025-12-02 07:07:58 -08:00

3.3 KiB
Raw Blame History

Інструкції для застосування міграцій MicroDAO Dashboard

Варіант 1: Використання скрипта (рекомендовано)

На NODE1 (сервер з базою даних):

# Перейти в директорію проєкту
cd /path/to/microdao-daarion

# Застосувати міграції
./scripts/apply_microdao_dashboard_migrations.sh postgres daarion localhost

Якщо база даних на іншому хості:

./scripts/apply_microdao_dashboard_migrations.sh postgres daarion your-db-host

Варіант 2: Ручне застосування

Крок 1: Застосувати міграцію 044

psql -U postgres -d daarion -f migrations/044_microdao_activity.sql

Крок 2: Застосувати міграцію 045

psql -U postgres -d daarion -f migrations/045_microdao_stats.sql

Крок 3: Застосувати seed-дані

psql -U postgres -d daarion -f docs/sql/seed_microdao_activity_daarion.sql

Варіант 3: Через Docker (якщо БД в контейнері)

# Знайти контейнер з PostgreSQL
docker ps | grep postgres

# Застосувати міграції
docker exec -i <postgres-container-name> psql -U postgres -d daarion < migrations/044_microdao_activity.sql
docker exec -i <postgres-container-name> psql -U postgres -d daarion < migrations/045_microdao_stats.sql
docker exec -i <postgres-container-name> psql -U postgres -d daarion < docs/sql/seed_microdao_activity_daarion.sql

Перевірка результатів

Перевірити таблицю активності:

SELECT COUNT(*) FROM microdao_activity WHERE microdao_slug = 'daarion';
-- Має повернути 10 записів

Перевірити структуру:

\d microdao_activity

Перевірити нові стовпці:

SELECT column_name, data_type 
FROM information_schema.columns 
WHERE table_name = 'microdaos' 
  AND column_name IN ('citizens_count', 'rooms_count', 'agents_count', 'last_update_at');

Після застосування міграцій

  1. Перезапустити city-service:

    docker-compose restart city-service
    # або
    systemctl restart daarion-city-service
    
  2. Перезапустити web (якщо потрібно):

    docker-compose restart web
    
  3. Перевірити API:

    curl http://localhost:7001/city/microdao/daarion/dashboard
    

Troubleshooting

Помилка "relation already exists"

Якщо таблиця вже існує, міграції використовують CREATE TABLE IF NOT EXISTS, тому це нормально.

Помилка "column already exists"

Якщо стовпці вже існують, міграція використовує ADD COLUMN IF NOT EXISTS, тому це нормально.

Помилка "duplicate key value"

Якщо seed-дані вже застосовані, можна пропустити цей крок або видалити існуючі записи:

DELETE FROM microdao_activity WHERE microdao_slug = 'daarion';
-- Потім застосувати seed-дані знову