Database
1. Database
Refreshed against dev-next. The primary application database is PostgreSQL.
1.1. Current data architecture
Default Laravel connection:
pgsqlPrimary schema/database for the application: PostgreSQL
Additional named connections exist for CCC and selected integrations
Some MariaDB/MySQL connections remain for legacy or peripheral systems; do not treat MariaDB as the primary app database
1.2. Coding guidelines
Prefer Eloquent models and relationships
Keep business logic in PHP, not in database-specific procedures or complex raw SQL
Avoid driver-specific queries unless there is a clear reviewed need
Never use obsolete PHP mysql APIs
Use
DB::sparingly and only when Eloquent cannot express the query cleanly
1.3. Schema conventions
Table names are singular (
contact, notcontacts)Foreign keys use
tablename_idand are indexedDefault foreign-key delete behavior is
restrictunless explicitly approved otherwiseStructured data uses
$table->json(...)(JSONB on PostgreSQL)Do not use DB
ENUMtypes; prefer string columns with validation or check constraints
1.4. Migrations
New migrations should:
Live in global
database/migrations/Extend
Database\Migrations\BaseMigrationSet
$migrationScopeto eitherdatabaseorsystemAvoid mixing database changes and system/filesystem changes in one migration
Avoid re-declaring generic columns already provided by
BaseMigrationhelpers such as id/timestamps/soft deletes when using the generic table helpers
See Migrations for details.
1.5. Models
Module models live in
Modules/<Module>/EntitiesModels used by Base MVC typically extend
App\BaseModelRelation select sources should expose
html_list(): arrayreturningid => label