Skip to content

Commit f35322d

Browse files
dwirzDominique Wirz
andauthored
feat: Add additional checks for numeric precision and string type validation in migration generation (#401)
Co-authored-by: Dominique Wirz <[email protected]>
1 parent ef63351 commit f35322d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/migrations/generate.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,23 @@ export class MigrationGenerator {
896896
} else if (col.data_type !== 'numeric') {
897897
return true;
898898
}
899+
if (field.precision && col.numeric_precision && field.precision !== col.numeric_precision) {
900+
return true;
901+
}
902+
if (field.scale && col.numeric_scale && field.scale !== col.numeric_scale) {
903+
return true;
904+
}
905+
}
906+
if (field.type === 'String') {
907+
if (field.large && col.data_type !== 'text') {
908+
return true;
909+
}
910+
if (field.stringType === 'richText' && col.data_type !== 'text') {
911+
return true;
912+
}
913+
if (!field.large && field.maxLength && col.max_length && field.maxLength !== col.max_length) {
914+
return true;
915+
}
899916
}
900917
}
901918

0 commit comments

Comments
 (0)