# WP2-004 – Schema and Migrations

Status: Completed by ED, pending PL integration test.

## Implemented

- DM002 v0.3 documentation
- forward-only baseline migration `0001_create_dm002_baseline.sql`
- file discovery with monotonic version ordering
- SHA-256 checksums and immutable applied migrations
- technical `schema_migration` registry
- database-scoped advisory lock via `GET_LOCK` / `RELEASE_LOCK`
- explicit CLI entry point `php tools/migrate.php`
- SQL statement splitting for the current MySQL/MariaDB migration scope
- schema and migration regression test
- no migration integration in the HTTP Composition Root

## Configuration

The existing local `config/database.php` is used. The package does not replace credentials or environment-specific database configuration.

The target database must already exist and the configured database user must have the privileges required for DDL and the advisory lock functions.

## Commands

```bash
php tests/Migration/SchemaAndMigrationsTest.php
php tools/migrate.php
php tools/migrate.php
```

The second migration run must apply zero migrations and report the baseline as skipped.

## Scope boundary

No repositories, Data Mappers, rehydration, aggregate persistence, or transactional application integration are included.
