Skip to content

Commit

Permalink
fix: set missing head
Browse files Browse the repository at this point in the history
  • Loading branch information
eseliger committed May 19, 2018
1 parent fc6b695 commit 437db56
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 4 deletions.
5 changes: 4 additions & 1 deletion dist/adapters/postgres.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/adapters/postgres.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/cli.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/cli.js.map

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/adapters/postgres.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ export class PostgresAdapter extends DbAdapter {
* Logs a task to the database. Sets the task ID
*/
public async beginMigrationTask(task: Task): Promise<void> {
if (!task.head) {
throw new Error('Task has no HEAD')
}
await this.client.query(`BEGIN TRANSACTION`)
try {
await this.client.query(`LOCK TABLE "merkel_meta"`)
Expand All @@ -83,7 +86,7 @@ export class PostgresAdapter extends DbAdapter {
${task.migration.name},
${task.type},
${task.commit ? task.commit.sha1 : null},
${task.head ? task.head.sha1 : null}
${task.head.sha1}
)
RETURNING id
`)
Expand Down
1 change: 1 addition & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ yargs.command(
// create pending tasks
for (const task of tasks) {
try {
task.head = head
await adapter.beginMigrationTask(task)
} catch (error) {
if (error instanceof PendingMigrationFoundError) {
Expand Down

0 comments on commit 437db56

Please sign in to comment.