Skip to content
This repository was archived by the owner on Oct 7, 2024. It is now read-only.

Commit 56e9cd5

Browse files
Merge pull request #101 from liuyang25/fix_sequence_not_reset
fix SEQUENCE field too long cause not reset the SEQUENCE
2 parents d8185c9 + aa69963 commit 56e9cd5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

v3-mongodb-v3-sql/dialects/postgres.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ module.exports = (knex, inspector) => ({
2222
let result = await knex.raw('select max(id) from ??', [table]);
2323
const max = result.rows[0].max;
2424

25+
const nextVal =`${table.slice(0, 56)}_id_seq`;
2526
if (max) {
26-
await knex.raw(`ALTER SEQUENCE ?? RESTART WITH ??;`, [table + '_id_seq', max + 1]);
27+
await knex.raw('ALTER SEQUENCE ?? RESTART WITH ??;', [nextVal, max + 1]);
2728
}
2829
}
2930
},

0 commit comments

Comments
 (0)