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

Commit 1006081

Browse files
committed
fix: sort table indexes to ensure stable schema generation
1 parent 6e756b5 commit 1006081

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

packages/cli/src/actions/pull/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,14 @@ export function syncTable({
328328
);
329329
}
330330

331-
table.indexes.forEach((index) => {
331+
// Sort indexes: unique indexes first, then other indexes
332+
const sortedIndexes = table.indexes.sort((a, b) => {
333+
if (a.unique && !b.unique) return -1;
334+
if (!a.unique && b.unique) return 1;
335+
return 0;
336+
});
337+
338+
sortedIndexes.forEach((index) => {
332339
if (index.predicate) {
333340
//These constraints are not supported by Zenstack, because Zenstack currently does not fully support check constraints. Read more: https://pris.ly/d/check-constraints
334341
console.warn(

0 commit comments

Comments
 (0)