# Run All Chart of Accounts Setup Steps

## Quick Execution

Since we're not on the Proxmox host, here are the exact commands to run:

### Step 1: Grant Database Permissions (On Proxmox Host)

**SSH to Proxmox host and run:**

```bash
ssh root@192.168.11.10

# Grant permissions
pct exec 10100 -- bash -c "su - postgres -c \"psql -d postgres << 'EOF'
GRANT CONNECT ON DATABASE dbis_core TO dbis;
GRANT ALL PRIVILEGES ON DATABASE dbis_core TO dbis;
ALTER USER dbis CREATEDB;
EOF\""

pct exec 10100 -- bash -c "su - postgres -c \"psql -d dbis_core << 'EOF'
GRANT ALL ON SCHEMA public TO dbis;
GRANT CREATE ON SCHEMA public TO dbis;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO dbis;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO dbis;
EOF\""
```

### Step 2: Run Migration (From Local Machine)

```bash
cd /home/intlc/projects/proxmox/dbis_core
./scripts/run-chart-of-accounts-migration.sh
```

---

## One-Line Commands

### Grant Permissions (One-liner for Proxmox Host)

```bash
ssh root@192.168.11.10 "pct exec 10100 -- bash -c \"su - postgres -c \\\"psql -d postgres -c 'GRANT CONNECT ON DATABASE dbis_core TO dbis; GRANT ALL PRIVILEGES ON DATABASE dbis_core TO dbis; ALTER USER dbis CREATEDB;'\\\" && su - postgres -c \\\"psql -d dbis_core -c 'GRANT ALL ON SCHEMA public TO dbis; GRANT CREATE ON SCHEMA public TO dbis; ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO dbis; ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO dbis;'\\\"\""
```

### Then Run Migration

```bash
cd /home/intlc/projects/proxmox/dbis_core && ./scripts/run-chart-of-accounts-migration.sh
```

---

## Expected Output

After permissions are granted and migration runs, you should see:

```
✅ Chart of Accounts initialized successfully!
✅ Total accounts created: 50+

📊 Account Summary:
   Assets: 15+
   Liabilities: 8+
   Equity: 6+
   Revenue: 5+
   Expenses: 8+
```

---

**Status**: Ready to execute - just run the commands above!
