<!-- Source: @site/projects/sqlens-for-laravel/docs/rules/my-l6-innodb-row-format-not-dynamic.md -->
<!-- Canonical: https://docs.pushery.com/sqlens-for-laravel/rules/my-l6-innodb-row-format-not-dynamic/ -->

# MY.L6.INNODB_ROW_FORMAT_NOT_DYNAMIC — the 767-byte ceiling that aborts a deploy halfway

> A server creating InnoDB tables as COMPACT gives them a 767-byte index key limit, so the first unique string index fails mid-deploy.

- **Category:** safety
- **Level:** 6
- **Confidence:** deterministic
- **Downtime class:** none
- **Stability:** stable
- **Suites:** audit
- **Applies to:** MySQL 8.4
- **Not transferable to MariaDB:** this page describes MySQL 8.4 behavior. MariaDB answers the
  same driver and does not share these semantics, so SQLens refuses it outright rather than
  reasoning about it — see [drivers/unsupported](https://docs.pushery.com/sqlens-for-laravel/drivers/unsupported.md).

Laravel's schema builder never emits an explicit `ROW_FORMAT`, so **every** table it creates takes
the server default.

Under `COMPACT` or `REDUNDANT` that default carries the **767-byte** index key prefix ceiling
instead of 3072. At utf8mb4's four bytes per character, that is 191 characters — so the first

```php
Schema::create('users', function (Blueprint $table): void {
    $table->string('email')->unique();
});
```

(VARCHAR(255) × 4 = 1020 bytes) aborts with `ERROR 1071 Specified key was too long`.

## The timing is the damage

It aborts **mid-deploy**. Some migrations are applied, some are not, on a server every other check
called healthy.

## Why the usual workaround is worse than the fix

The field answer everyone reaches for is `Schema::defaultStringLength(191)` in a service provider.
That converts a one-line **server** misconfiguration into a permanent, application-wide narrowing of
every string column — invisible to whoever reads the migrations later, and carried onto servers that
never had the problem.

## Flagged

```sql
SET GLOBAL innodb_default_row_format = COMPACT;
```

## Preferred

```sql
SET GLOBAL innodb_default_row_format = DYNAMIC;
```

## What this rule does not report

A server correctly handing out `DYNAMIC` while the catalog still holds tables created years ago under
an older default.

There is nothing in the configuration to fix there. Reporting it would send a reader to a file that
is already correct while never naming the actual work — an `ALTER TABLE … ROW_FORMAT=DYNAMIC` rebuild
per table. That is a statement about the **schema**, not the server, and it belongs to a schema rule.

When the server default *is* wrong, the finding does name the tables already on a legacy format, so
you know whether a rebuild is owed on top of the configuration change.

## What is read

The variable is `GLOBAL`-only — there is no session value to read, and none is looked for. The
comparison folds case: MySQL reports `dynamic` while the manual and every config file write
`DYNAMIC`, and a strict comparison would flag the exact value the expectation asks for.

## Sources

- [InnoDB row formats](https://dev.mysql.com/doc/refman/8.4/en/innodb-row-format.html) — MySQL 8.4
- [InnoDB limits](https://dev.mysql.com/doc/refman/8.4/en/innodb-limits.html) — MySQL 8.4
- [InnoDB startup options and system variables](https://dev.mysql.com/doc/refman/8.4/en/innodb-parameters.html) — MySQL 8.4

<!-- BEGIN generated: remediation -->
## The fix material this rule carries

A finding from this rule carries a payload whose strategy is `none`: this rule has looked,
and there is no safe standard sequence. That is a conclusion rather than an omission — a
finding with no payload at all says only that nobody wrote one.

The payload is material for you or an agent to apply. SQLens writes no migration and runs no
DDL. See [the remediation payload](https://docs.pushery.com/sqlens-for-laravel/remediation-schema.md) for every field, the placeholder
semantics, and the version rules a consumer has to follow.
<!-- END generated: remediation -->
