Skip to content
This repository was archived by the owner on Mar 1, 2026. It is now read-only.

Commit 9dcf2ab

Browse files
committed
fix(cli): filter out auto-generated MySQL indexes
Prevents foreign key indexes created automatically by MySQL from appearing in the introspected schema. This ensures the output reflects manually defined indexes and avoids redundancy in schema definitions.
1 parent 2b6354a commit 9dcf2ab

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

  • packages/cli/src/actions/pull/provider

packages/cli/src/actions/pull/provider/mysql.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,20 @@ export const mysql: IntrospectionProvider = {
146146
(a.ordinal_position ?? 0) - (b.ordinal_position ?? 0)
147147
);
148148

149+
// Filter out auto-generated FK indexes (MySQL creates these automatically)
150+
// Pattern: {Table}_{column}_fkey for single-column FK indexes
151+
const filteredIndexes = (indexes || []).filter(
152+
(idx: { name: string; columns: { name: string }[] }) =>
153+
!(idx.columns.length === 1 && idx.name === `${row.name}_${idx.columns[0]?.name}_fkey`)
154+
);
155+
149156
tables.push({
150157
schema: '', // MySQL doesn't support multi-schema
151158
name: row.name,
152159
type: row.type as 'table' | 'view',
153160
definition: row.definition,
154161
columns: sortedColumns,
155-
indexes: indexes || [],
162+
indexes: filteredIndexes,
156163
});
157164
}
158165

0 commit comments

Comments
 (0)