65 lines
1.5 KiB
Markdown
65 lines
1.5 KiB
Markdown
# Phase 7: Database Updates
|
|
|
|
## Agent Assignment
|
|
**Primary Agent:** infra-agent
|
|
**Duration:** 15 minutes
|
|
|
|
## Prerequisites
|
|
- Phase 5 (Network Simplification) must be complete
|
|
|
|
## Objectives
|
|
1. Verify database schema has no tenant_id columns
|
|
2. Ensure all tables use user_id isolation only
|
|
3. Verify migrations don't reference tenants
|
|
|
|
## Step-by-Step Instructions
|
|
|
|
### Step 1: Connect to Database
|
|
```bash
|
|
docker compose exec mvp-postgres psql -U postgres -d motovaultpro
|
|
```
|
|
|
|
### Step 2: Verify No tenant_id Columns
|
|
```sql
|
|
SELECT table_name, column_name
|
|
FROM information_schema.columns
|
|
WHERE table_schema = 'public'
|
|
AND column_name = 'tenant_id';
|
|
```
|
|
**Expected:** 0 rows
|
|
|
|
### Step 3: Verify user_id Columns Exist
|
|
```sql
|
|
SELECT table_name
|
|
FROM information_schema.columns
|
|
WHERE table_schema = 'public'
|
|
AND column_name = 'user_id';
|
|
```
|
|
**Expected:** vehicles, fuel_logs, maintenance_logs, documents, etc.
|
|
|
|
### Step 4: Check Migrations
|
|
```bash
|
|
grep -r "tenant" backend/src/_system/migrations/
|
|
# Expected: 0 results (no tenant references)
|
|
```
|
|
|
|
### Step 5: Verify Platform Schema (if needed)
|
|
If mvp-platform uses separate schema:
|
|
```sql
|
|
CREATE SCHEMA IF NOT EXISTS vehicles_platform;
|
|
-- Platform service will initialize its tables
|
|
```
|
|
|
|
## Validation Criteria
|
|
- [ ] No tenant_id columns in application database
|
|
- [ ] All tables have user_id for isolation
|
|
- [ ] Migrations have no tenant references
|
|
- [ ] Database accessible from mvp-backend and mvp-platform
|
|
|
|
## Update EXECUTION-STATE.json
|
|
```json
|
|
{
|
|
"phases": {"7": {"status": "completed", "validation_passed": true}}
|
|
}
|
|
```
|