Data layer contracts

From Bottelet/DaybydayCRM · View interactive version

Data layer contracts is an AI agent skill from the GitHub repository Bottelet/DaybydayCRM. Defines the schema-to-factory-to-seeder contract chain — NOT NULL alignment, factory/seeder ownership boundaries, and schema drift rules

How to use this skill

Skill file

Data Layer Contracts

Purpose

Defines the contract chain from migration schema to factory to seeder, and prevents drift between them.


Schema Contract

Every NOT NULL column defined in a migration must be supported by:

This is a schema-only rule, not a validation rule. MySQL/MariaDB is the canonical database — SQLite differences are invalid for schema validation assumptions.


Factory Rules

Factories MUST:

Factories MUST NOT:

If a migration introduces a NOT NULL column, the factory MUST be updated immediately — omission is invalid state.

Factories SHOULD align with service-layer expectations but do NOT depend on it: service layer = behavior, factory = valid structure.


Seeder Rules

Seeders MUST:

Seeders MUST NOT:

Seeders assemble data. They do not define data correctness.


Drift Triggers

The following indicate schema drift: migration changes, factory mismatch, seeder mismatch, SQLSTATE constraint violations, CI vs local DB mismatch.

Schema validation requires migrate:fresh + seed before running test suites.


Identity Rule

Primary keys are non-deterministic. Tests MUST NOT rely on hardcoded IDs.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.