Skip to content

Commit

Permalink
Error on autoincs without indexes on MySQL
Browse files Browse the repository at this point in the history
  • Loading branch information
emmatown committed May 30, 2022
1 parent 737aa22 commit 4451fa4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/core/src/fields/types/integer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ export const integer =
`The integer field at ${meta.listKey}.${meta.fieldKey} specifies defaultValue: { kind: 'autoincrement' }, this is not supported on SQLite`
);
}
if (meta.provider === 'mysql' && !isIndexed) {
throw new Error(
`The integer field at ${meta.listKey}.${meta.fieldKey} specifies defaultValue: { kind: 'autoincrement' }, but doesn't specify isIndexed: true or 'unique'. autoincrement fields on MySQL must have an index.`
);
}
if (isNullable !== false) {
throw new Error(
`The integer field at ${meta.listKey}.${meta.fieldKey} specifies defaultValue: { kind: 'autoincrement' } but doesn't specify db.isNullable: false.\n` +
Expand Down

0 comments on commit 4451fa4

Please sign in to comment.