Skip to content

Commit

Permalink
fix: handle migration timestamps correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
joakimbeng committed Dec 19, 2019
1 parent b76c85b commit 58068ea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"test": "xo",
"test:integration": "npm run -s immigration",
"release": "standard-version",
"immigration": "immigration --use [./ --connectionUri \"postgres://postgres@${POSTGRES_HOST:-localhost}/immigration_postgres\" --table migrations] -d migrations up --all",
"immigration": "immigration --use [./ --connectionUri \"postgres://postgres@${POSTGRES_HOST:-localhost}/immigration_postgres\" --table migrations] -d migrations up --new",
"semantic-release": "semantic-release"
},
"repository": {
Expand Down Expand Up @@ -40,7 +40,8 @@
"prettier": true,
"rules": {
"default-param-last": 0,
"unicorn/filename-case": 0
"unicorn/filename-case": 0,
"padding-line-between-statements": 0
}
},
"devDependencies": {
Expand Down
13 changes: 10 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,16 @@ exports.init = function({config, ...options} = {}, dir) {
};

const executed = () => {
return prepare().then(() =>
pool.any(sql`SELECT * FROM ${sql.identifier([table])} WHERE name <> ${LOCK_ID};`)
);
return prepare()
.then(() => pool.any(sql`SELECT * FROM ${sql.identifier([table])} WHERE name <> ${LOCK_ID};`))
.then(rows =>
rows.map(row => {
if (typeof row.date === 'number') {
row.date = new Date(row.date);
}
return row;
})
);
};

return {log, unlog, lock, unlock, isLocked, executed};
Expand Down

0 comments on commit 58068ea

Please sign in to comment.