# /database/data

CSV seed data for the K12-EduSol backend. Three directories, three seeding contexts.

```
database/data/
├─ landlord/           ← landlord (public) schema, once per platform
├─ defaults/           ← every new tenant, at provisioning
├─ demo/               ← optional: demo tenant for local dev
└─ setup-templates/    ← download templates for admins' bulk imports
```

## Seeding flow

```
┌──────────────────┐   composer run setup
│ LandlordSeeder   │◄──── reads /landlord/*.csv
└────────┬─────────┘
         │
         │  Blouza → "Provision institution Foo"
         ▼
┌──────────────────────────┐
│ ProvisionInstitution     │◄── reads /defaults/*.csv
│  (creates tenant schema, │
│  runs tenant migrations, │
│  runs default seeders)   │
└────────┬─────────────────┘
         │
         │  admin → "Bulk import students"
         ▼
┌──────────────────────────┐
│ BulkImportController     │◄── reads uploaded CSV
│  (validates against       │    that matches
│  setup-templates shape)   │    /setup-templates/*.csv
└──────────────────────────┘
```

## Directories

| Directory | When it runs | Who touches it |
|---|---|---|
| `landlord/` | Once, at platform install | Dev ops / Blouza engineering |
| `defaults/` | Every time an institution is provisioned | Code-managed; edit here means every future tenant changes |
| `demo/` | On demand (`php artisan tenant:seed-demo`) | Dev only — do not use in production |
| `setup-templates/` | Downloaded by admins via UI | End users adjust & upload during onboarding |

## Editing defaults

A change to `defaults/*.csv` affects every **future** tenant only. Existing tenants are not retroactively seeded. To backfill, write a dedicated migration or one-off seeder.

## Permission pattern syntax (in `defaults/role_permissions.csv`)

- `*` — all permissions
- `module.*` — all actions on module + all its tabs
- `module.tab.*` — all actions on a specific tab
- `module.action` — single action on module
- `module.tab.action` — single action on specific tab

Actions: `view`, `create`, `edit`, `delete`, `approve`.

## Deprecated templates

Some templates in `setup-templates/` come from an older tertiary-education scaffolding and are **not used** in the K-12 product. They remain untouched but will be removed in Phase 15 cleanup:

- `faculties_template.csv`
- `departments_template.csv`
- `courses_template.csv`
- `semesters_template.csv`
- `academic_sessions_template.csv` (overlaps with `defaults/terms.csv` — will reconcile)
- `jamb_results_template.csv` (may be repurposed for SS3 leavers if JAMB tracking is added)

K-12 canonical paths are **program → grade_level → klass/section → subject**, not faculty/department/course.
