Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check table exists in current search path #93

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

slifty
Copy link

@slifty slifty commented Jul 13, 2022

This PR adds tests to PR #33 which will ultimately fix a bug where schemas are ignored when checking for the presence of a migrations table.

Note: the tests do fail when not using the patched code! Hooray!

Resolves #92

* If a `migrations` table did exist in a schema outside of the
  search path, `doesTableExist` would return true but the migration
  would then fail with 'relation "migrations" does not exist'
* See https://dba.stackexchange.com/a/86098 for the details on the query
* This new query makes it possible to have one `migrations` table per
  schema

Issue ThomWright#92 Migrations can't be run on multiple schemas in the same database

Co-authored-by: Remi Koenig <[email protected]>
@slifty slifty force-pushed the 92-fix-migration-schema-conflict branch from ef1705b to 2952d57 Compare July 13, 2022 16:55
slifty added a commit to PhilanthropyDataCommons/service that referenced this pull request Jul 13, 2022
Integration tests are slower than unit tests because they rely on
a database connection, so we want the ability to run them separately
depending on our environment.

Jest allows us to define different config files.  By creating a `base`
config we can define all of the common settings between unit and
integration tests, and then customize for each type in the respective
extended configs.

In addition to configuration this begins to define define some hooks
so that we can eventually run these tests in parallel.  Unfortunately
there is a bug in the migration library we're using which prevents that
kind of parallel migration within a single database / across multiple
schemas.  We have an open PR with a patch for that bug[1].

[1] ThomWright/postgres-migrations#93

Issue #43 Support integration tests
slifty added a commit to PhilanthropyDataCommons/service that referenced this pull request Jul 13, 2022
Integration tests are slower than unit tests because they rely on
a database connection, so we want the ability to run them separately
depending on our environment.

Jest allows us to define different config files.  By creating a `base`
config we can define all of the common settings between unit and
integration tests, and then customize for each type in the respective
extended configs.

In addition to configuration this begins to define define some hooks
so that we can eventually run these tests in parallel.  Unfortunately
there is a bug in the migration library we're using which prevents that
kind of parallel migration within a single database / across multiple
schemas.  We have an open PR with a patch for that bug[1].

[1] ThomWright/postgres-migrations#93

Issue #43 Support integration tests
slifty added a commit to PhilanthropyDataCommons/service that referenced this pull request Jul 13, 2022
Integration tests are slower than unit tests because they rely on
a database connection, so we want the ability to run them separately
depending on our environment.

Jest allows us to define different config files.  By creating a `base`
config we can define all of the common settings between unit and
integration tests, and then customize for each type in the respective
extended configs.

In addition to configuration this begins to define define some hooks
so that we can eventually run these tests in parallel.  Unfortunately
there is a bug in the migration library we're using which prevents that
kind of parallel migration within a single database / across multiple
schemas.  We have an open PR with a patch for that bug[1].

[1] ThomWright/postgres-migrations#93

Issue #43 Support integration tests
slifty added a commit to PhilanthropyDataCommons/service that referenced this pull request Jul 13, 2022
Integration tests are slower than unit tests because they rely on
a database connection, so we want the ability to run them separately
depending on our environment.

Jest allows us to define different config files.  By creating a `base`
config we can define all of the common settings between unit and
integration tests, and then customize for each type in the respective
extended configs.

In addition to configuration this begins to define define some hooks
so that we can eventually run these tests in parallel.  Unfortunately
there is a bug in the migration library we're using which prevents that
kind of parallel migration within a single database / across multiple
schemas.  We have an open PR with a patch for that bug[1].

I took out the explicit running of migrations because our integration
tests should now cover that (as they do run migrations).

[1] ThomWright/postgres-migrations#93

Issue #43 Support integration tests
slifty added a commit to PhilanthropyDataCommons/service that referenced this pull request Jul 15, 2022
Integration tests are slower than unit tests because they rely on
a database connection, so we want the ability to run them separately
depending on our environment.

Jest allows us to define different config files.  By creating a `base`
config we can define all of the common settings between unit and
integration tests, and then customize for each type in the respective
extended configs.

In addition to configuration this begins to define define some hooks
so that we can eventually run these tests in parallel.  Unfortunately
there is a bug in the migration library we're using which prevents that
kind of parallel migration within a single database / across multiple
schemas.  We have an open PR with a patch for that bug[1].

I took out the explicit running of migrations because our integration
tests should now cover that (as they do run migrations).

[1] ThomWright/postgres-migrations#93

Issue #43 Support integration tests
@slifty
Copy link
Author

slifty commented Apr 11, 2023

We're heading close to the one year anniversary of this PR -- I wanted to check to see if it might be possible to merge in. This bug currently means I can't run tests locally unless I manually destroy my public schema.

@ioannist
Copy link

would be nice to merge it; running into this issue too

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.

Migrations can't be run on multiple schemas in the same database
2 participants