Indexes¶
Single-column indexes¶
$t->string('email')->unique('users_email_unique');
$t->string('slug')->index('posts_slug_index');
Composite indexes¶
$t->unique(
['email', 'tenant_id'],
'users_tenant_email_unique'
);
$t->index(
['first_name', 'last_name'],
'users_name_index'
);
Diffing¶
Schemage supports:
- adding missing indexes
- dropping removed indexes
- replacing changed indexes with
DropIndex + AddIndex
The migration plan remains explicit and shows both operations. Internally, the operation sorter drops the old index before creating the replacement.
Dropping a secondary index does not directly delete table rows, so it does not require --force. It may still affect uniqueness guarantees or query performance and should be reviewed.
Primary indexes¶
Primary-key changes remain intentionally conservative. They can affect foreign keys, row identity, and table organization, so they should be handled manually for now.