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

PROBLEM: postgres migration broken #162

Closed
wants to merge 1 commit into from

Conversation

karolhrdina
Copy link

When i try to run migrate from upstream master i run into the following
problem:

kj@vrrr:~/repos/migrate-upstream/cli/build> ./migrate.linux-amd64 -source file:///home/kj/work/cncenter.git/behav-api/sql/ -database postgres://postgres:postgres@172.33.0.1:5432/?sslmode=disable -verbose up 1
2019/01/31 18:35:11 Start buffering 1/u initialize_db
2019/01/31 18:35:12 Read and execute 1/u initialize_db
2019/01/31 18:35:12 error: pq: relation "schema_migrations" does not exist in line 0: TRUNCATE "schema_migrations"

Postres is complaining:

2019-01-31 17:35:12.440 UTC [61] ERROR:  relation "schema_migrations" does not exist
2019-01-31 17:35:12.440 UTC [61] STATEMENT:  TRUNCATE "schema_migrations"

I am running postgres like this:
docker run --rm --net=behavnet --name postgres -p 5432:5432 -v /home/kj/temp:/tmp:rw postgres:10.6

I found an old closed issue
#93
which suggested that i might need priviliges:

postgres=# \du
                                   List of roles
 Role name |                         Attributes                         | Member of
-----------+------------------------------------------------------------+-----------
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}

Other than that, there was no other suggestion or resolution of that
issue.

With this commit built, i have no more problems:

kj@vrrr:~/repos/migrate/cli/build> ./migrate.linux-amd64 -source file:///home/kj/work/cncenter.git/behav-api/sql/ -database postgres://postgres:postgres@172.33.0.1:5432/?sslmode=disable -verbose up 1
2019/01/31 18:42:06 Start buffering 1/u initialize_db
2019/01/31 18:42:06 Read and execute 1/u initialize_db
2019/01/31 18:42:06 Finished 1/u initialize_db (read 12.662008ms, ran 155.706703ms)
2019/01/31 18:42:06 Finished after 169.958723ms
2019/01/31 18:42:06 Closing source and database

No more errors in postgres log.

When i try to run migrate from upstream master i run into the following
problem:
```bash
kj@vrrr:~/repos/migrate-upstream/cli/build> ./migrate.linux-amd64 -source file:///home/kj/work/cncenter.git/behav-api/sql/ -database postgres://postgres:postgres@172.33.0.1:5432/?sslmode=disable -verbose up 1
2019/01/31 18:35:11 Start buffering 1/u initialize_db
2019/01/31 18:35:12 Read and execute 1/u initialize_db
2019/01/31 18:35:12 error: pq: relation "schema_migrations" does not exist in line 0: TRUNCATE "schema_migrations"
```
Postres is complaining:
```
2019-01-31 17:35:12.440 UTC [61] ERROR:  relation "schema_migrations" does not exist
2019-01-31 17:35:12.440 UTC [61] STATEMENT:  TRUNCATE "schema_migrations"
```
I am running postgres like this:
`docker run --rm --net=behavnet --name postgres -p 5432:5432 -v /home/kj/temp:/tmp:rw postgres:10.6`

I found an old closed issue
golang-migrate#93
which suggested that i might need priviliges:
```bash
postgres=# \du
                                   List of roles
 Role name |                         Attributes                         | Member of
-----------+------------------------------------------------------------+-----------
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
```
Other than that, there was no other suggestion or resolution of that
issue.

With this commit built, i have no more problems:
```bash
kj@vrrr:~/repos/migrate/cli/build> ./migrate.linux-amd64 -source file:///home/kj/work/cncenter.git/behav-api/sql/ -database postgres://postgres:postgres@172.33.0.1:5432/?sslmode=disable -verbose up 1
2019/01/31 18:42:06 Start buffering 1/u initialize_db
2019/01/31 18:42:06 Read and execute 1/u initialize_db
2019/01/31 18:42:06 Finished 1/u initialize_db (read 12.662008ms, ran 155.706703ms)
2019/01/31 18:42:06 Finished after 169.958723ms
2019/01/31 18:42:06 Closing source and database
```

No more errors in postgres log.
@dhui
Copy link
Member

dhui commented Jan 31, 2019

Tests are failing.

Also, the schema migration table should not be hard-coded to the public schema. Have you checked your search_path?

@karolhrdina
Copy link
Author

Hi @dhui,
thanks for pointing me the right direction. The root cause of my problem was really in search_path.
Thus these changes are superfluous/wrong -> closing PR.

Thanks!

@karolhrdina karolhrdina closed this Feb 1, 2019
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.

None yet

2 participants