# Db2 LUW schema and migrations The Stage 5 tests use the configured `db2_local` connection. They create randomly named tables and a separate migration history table, then remove them. A skipped test means the connection was unavailable and provides no Db2 verification. ```sh APP_ENV=testing php artisan test --do-not-cache-result tests/Feature/Db2/SchemaTest.php APP_ENV=testing php artisan test --do-not-cache-result tests/Feature/Db2 APP_ENV=testing php artisan test --do-not-cache-result ``` The tests cover table creation, same-schema rename, conditional drop, adding and dropping columns, widening VARCHAR, catalog defaults and identity metadata, composite ordinary and unique index metadata and removal, foreign-key metadata and removal, and Laravel migration registration and rollback. ## Limits - Db2 applies its own rules to type conversions and dependent objects. Table renames require the source and target to be in the same schema. Tables with certain dependencies, including referential constraints, cannot be renamed. - Dropping columns and some type or nullability changes can leave a table in REORG-pending state. The driver does not run administrative utilities. Arrange for a Db2 administrator to run REORG before subsequent operations that require it. - Changing an identity column through Laravel's `change()` is unsupported. Unsigned types, column positioning, expression indexes, full-text indexes and spatial indexes are outside this implementation. - Laravel `unique()` creates a Db2 unique index. Db2 foreign keys require a referenced primary key or unique constraint. A standalone unique index does not establish that constraint. Foreign-key actions must be supported by Db2 for the chosen operation. - Column defaults are returned as SQL expressions from the catalog. Catalog output does not reconstruct generated expressions or every Db2 type attribute. - Laravel migration rollback runs `down()` and removes its history entry. The driver does not advertise transactional schema migrations. - Migration batch lookup casts query-builder `max('batch')` results to text so Laravel can perform numeric arithmetic through PDO_ODBC. This applies to custom migration history table names as well. ## Phase 7 data types and indexes - `char(length)` creates a fixed-width Db2 character column. `uuid()` uses `CHAR(36)` and leaves UUID validation and generation to the application. - `time()` uses Db2 TIME at whole-second precision. Fractional TIME precision raises an exception. Timestamp and datetime definitions accept Db2 fractional-second precision, and the catalog reports it for TIMESTAMP. - `renameIndex()` uses Db2's same-schema rename for an application-created index. It preserves key order and uniqueness. Db2 requires the target name to be available in that schema. - Time-zone-aware column types, binary UUID storage, expression indexes, and automatic REORG remain outside the verified scope. Run the focused live tests with: ```sh APP_ENV=testing php artisan test --do-not-cache-result tests/Feature/Db2/SchemaTypesAndIndexesTest.php ``` ## Selecting the default schema Set `DB2_SCHEMA` to use a specific schema on the database selected by `DB2_DSN`. If omitted or blank, the connector retains the DSN or server default and reads `CURRENT SCHEMA` for Laravel catalog lookups. Set `DB2_SCHEMA=AAMEDIUK` explicitly to retain the former default.