# Fix DEV Database Permissions

## The Problem

SQLite needs write access to both the database file AND the directory it's in (to create temporary files like journals and WAL files).

Currently:
- ✅ Database file: `data-dev/seismo_fleet.db` - permissions fixed
- ❌ Directory: `data-dev/` - still owned by root

## The Fix

Run this command to fix the directory ownership:

```bash
sudo chown -R serversdown:serversdown /home/serversdown/sfm/seismo-fleet-manager/data-dev/
```

Then run the migration again:

```bash
python3 scripts/migrate_dev_db.py
```

## Full Setup Commands

Here's the complete sequence:

```bash
cd /home/serversdown/sfm/seismo-fleet-manager

# Fix directory ownership (includes all files inside)
sudo chown -R serversdown:serversdown data-dev/

# Migrate schema
python3 scripts/migrate_dev_db.py

# Add test data
python3 scripts/add_test_slms.py
python3 scripts/add_test_modems.py
```

## Verify It Worked

After running the migration, you should see:

```
Migrating DEV database to add SLM columns...
============================================================
✓ Added column: slm_host
✓ Added column: slm_tcp_port
✓ Added column: slm_model
✓ Added column: slm_serial_number
✓ Added column: slm_frequency_weighting
✓ Added column: slm_time_weighting
✓ Added column: slm_measurement_range
✓ Added column: slm_last_check
============================================================
DEV database migration completed!
```

Then the test data scripts should work without errors!
