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

115 lines
3.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Інструкції для застосування міграцій MicroDAO Dashboard
## Варіант 1: Використання скрипта (рекомендовано)
### На NODE1 (сервер з базою даних):
```bash
# Перейти в директорію проєкту
cd /path/to/microdao-daarion
# Застосувати міграції
./scripts/apply_microdao_dashboard_migrations.sh postgres daarion localhost
```
Якщо база даних на іншому хості:
```bash
./scripts/apply_microdao_dashboard_migrations.sh postgres daarion your-db-host
```
## Варіант 2: Ручне застосування
### Крок 1: Застосувати міграцію 044
```bash
psql -U postgres -d daarion -f migrations/044_microdao_activity.sql
```
### Крок 2: Застосувати міграцію 045
```bash
psql -U postgres -d daarion -f migrations/045_microdao_stats.sql
```
### Крок 3: Застосувати seed-дані
```bash
psql -U postgres -d daarion -f docs/sql/seed_microdao_activity_daarion.sql
```
## Варіант 3: Через Docker (якщо БД в контейнері)
```bash
# Знайти контейнер з 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
```
## Перевірка результатів
### Перевірити таблицю активності:
```sql
SELECT COUNT(*) FROM microdao_activity WHERE microdao_slug = 'daarion';
-- Має повернути 10 записів
```
### Перевірити структуру:
```sql
\d microdao_activity
```
### Перевірити нові стовпці:
```sql
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:
```bash
docker-compose restart city-service
# або
systemctl restart daarion-city-service
```
2. Перезапустити web (якщо потрібно):
```bash
docker-compose restart web
```
3. Перевірити API:
```bash
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-дані вже застосовані, можна пропустити цей крок або видалити існуючі записи:
```sql
DELETE FROM microdao_activity WHERE microdao_slug = 'daarion';
-- Потім застосувати seed-дані знову
```