Skip to content

Conversation

@alxndrsn
Copy link
Contributor

@alxndrsn alxndrsn commented Jan 14, 2025

  • implement replacement for existing knex migrator

Reviewing

To reduce changeset to non-migrations:

git diff --ignore-all-space master -- $(git diff master --name-only | grep -v '^lib/model/migrations/')

Before merging

Confirm that no (additional) migrations have been accidentally renamed:

git diff --name-status --diff-filter=R master -- ./lib/model/migrations/ | awk '
  BEGIN { renamed = 0 }
  {
    n1 = split($2, a1, "/");
    n2 = split($3, a2, "/");
    if(a1[n1] != a2[n2]) {
      ++renamed
      print "name mismatch: " $2 " vs " $3
    }
  }
  END {
    print "-----"
    print "checked: " NR
    print "renamed: " renamed
    if(renamed > 0) {
      exit 1
    }
  }
'

TODO

What has been done to verify that this works as intended?

CI

Why is this the best possible solution? Were any other approaches considered?

Could use slonik instead, but seems better to tie implementation to a lower-level library, especially given concerns about upgrading to a more recent slonik (there are large API changes) and/or possibility of moving to an alternative to slonik.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

Intended effects: none
Possible effects: break production databases

Does this change require updates to the API documentation? If so, please update docs/api.yaml as part of this PR.

Shouldn't require docs changes.

Before submitting this PR, please make sure you have:

  • run make test and confirmed all checks still pass OR confirm CircleCI build passes
  • verified that any code from external sources are properly credited in comments or that everything is internally sourced

spwoodcock pushed a commit to spwoodcock/central-backend that referenced this pull request May 12, 2025
Noticed while working on getodk#1363.

Currently, when a postgres error has additional details, `run-migrations.js` will swallow these details.

# Example

## migration

```js
module.exports = {
  down: () => {},
  up: db => db.raw(`
    INSERT INTO config (key) VALUES('a');
    INSERT INTO config (key) VALUES('a');
  `),
}
```

## logging - previous `master`

```
Error: INSERT INTO config (key) VALUES('a'); INSERT INTO config (key) VALUES('a') - duplicate key value violates unique constraint "config_pkey"
```

## logging - this commit

```
Error: INSERT INTO config (key) VALUES('a'); INSERT INTO config (key) VALUES('a') - duplicate key value violates unique constraint "config_pkey" (Key (key)=(a) already exists.)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant