> ## Documentation Index
> Fetch the complete documentation index at: https://geni.masiting.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Offline Schema Inference

> How SchemaReader reconstructs database column types directly from migration files.

## Reconstructing Database State from Migrations

In Laravel, your migrations are the single source of truth for your database schema. Geni includes `Geni\SchemaReader`, a migration replay engine that parses PHP migration files into an in-memory `DatabaseSchema` object.

### Supported Blueprint Methods

`SchemaReader` recognizes all standard Laravel migration Blueprint methods:

| Category      | Blueprint Methods                                              | OpenAPI Type | OpenAPI Format       |
| ------------- | -------------------------------------------------------------- | ------------ | -------------------- |
| Identifiers   | `id()`, `increments()`, `bigIncrements()`                      | `integer`    |                      |
| UUIDs / ULIDs | `uuid()`, `ulid()`, `foreignUuid()`, `foreignUlid()`           | `string`     | `uuid` / `ulid`      |
| Text          | `string()`, `text()`, `mediumText()`, `longText()`, `char()`   | `string`     |                      |
| Numbers       | `integer()`, `bigInteger()`, `smallInteger()`, `tinyInteger()` | `integer`    |                      |
| Decimals      | `decimal()`, `float()`, `double()`                             | `number`     |                      |
| Booleans      | `boolean()`                                                    | `boolean`    |                      |
| Dates & Times | `date()`, `datetime()`, `timestamp()`, `timestamps()`          | `string`     | `date` / `date-time` |
| JSON          | `json()`, `jsonb()`                                            | `object`     |                      |

### Supported Migration Operations

`SchemaReader` tracks the chronological evolution of your schema:

* **Table Creation**: `Schema::create('users', function (Blueprint $table) { ... })`
* **Table Alteration**: `Schema::table('users', function (Blueprint $table) { ... })`
* **Adding Columns**: New columns added to existing tables
* **Dropping Columns**: `$table->dropColumn('legacy_field')` removes the column from the in-memory schema
* **Renaming Columns**: `$table->renameColumn('old', 'new')`
* **Dropping Tables**: `Schema::drop('posts')`, `Schema::dropIfExists('tags')`
* **Renaming Tables**: `Schema::rename('old_name', 'new_name')`
* **Macros**: Expands `id()`, `timestamps()`, `morphs()`, `nullableMorphs()`, `uuidMorphs()`, and `foreignIdFor()`.

## Schema Overrides Escape Hatch

If your application uses raw SQL statements inside migrations (e.g., `DB::statement("ALTER TABLE ...")`) or unresolvable third-party macros, you can define manual overrides in `config/geni.php`:

```php config/geni.php theme={null}
'schema_overrides' => [
    'users.custom_field' => 'string',
    'orders.geo_location' => 'object',
],
```

Whenever Geni encounters a field that could not be resolved from migrations, it consults `schema_overrides` before falling back to `string`.
