Skip to content

Commit

Permalink
pr feedback + prettier config
Browse files Browse the repository at this point in the history
  • Loading branch information
derrickmehaffy committed Sep 1, 2022
1 parent 82e56ff commit 6aba759
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 9 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
endOfLine: 'lf',
semi: true,
singleQuote: true,
tabWidth: 2,
trailingComma: 'es5',
printWidth: 100,
arrowParens: 'always',
};
7 changes: 3 additions & 4 deletions v3-mongodb-v3-sql/dialects/postgres.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,25 @@ module.exports = (knex, inspector) => ({
},

async beforeMigration() {
// await knex.raw(`SET session_replication_role = 'replica';`);
// do nothing for postgres
},

async afterMigration() {
const tableList = await inspector.tables();

// restart sequence for tables
for (const table of tableList) {
let result = await knex.raw("select max(id) from ??", [table]);
let result = await knex.raw('select max(id) from ??', [table]);
const max = result.rows[0].max;

if (max) {
await knex.raw(
`
ALTER SEQUENCE ?? RESTART WITH ??;
`,
[table + "_id_seq", max + 1]
[table + '_id_seq', max + 1]
);
}
}
// await knex.raw(`SET session_replication_role = 'origin';`);
},
});

0 comments on commit 6aba759

Please sign in to comment.