nkonev / r2dbc-migrate

R2DBC database migration library
https://nkonev.name/post/136
Apache License 2.0
99 stars 9 forks source link

PostgreSQL Error #8

Closed robbydf closed 4 years ago

robbydf commented 4 years ago

I'm running the R2DBC Migrate with only the version 1 of my migration scripts. The PostgreSQL is empty. During startup, here is my error logs

`2020-08-18 11:36:58.807+0200 INFO 26064 --- [ restartedMain] n.n.r.m.a.R2dbcMigrateAutoConfiguration : Starting R2DBC migration 2020-08-18 11:36:58.809+0200 INFO 26064 --- [ restartedMain] n.n.r.m.c.R2dbcMigrate : Configured with R2dbcMigrateProperties{connectionMaxRetries=500, resourcesPaths=[classpath:/db/migration/*.sql], chunkSize=1000, dialect=POSTGRESQL, validationQuery='select '42' as result', validationQueryExpectedResultValue='42', validationQueryTimeout=PT5S, validationRetryDelay=PT1S, acquireLockRetryDelay=PT1S, acquireLockMaxRetries=100, fileCharset=UTF-8, waitForDatabase=true, migrationsSchema='null', migrationsTable='migrations', migrationsLockTable='migrations_lock'} 2020-08-18 11:36:58.904+0200 INFO 26064 --- [ restartedMain] n.n.r.m.c.R2dbcMigrate : Creating new test connection 2020-08-18 11:36:59.557+0200 INFO 26064 --- [actor-tcp-nio-1] n.n.r.m.c.R2dbcMigrate : Comparing expected value '42' with provided result '42' 2020-08-18 11:36:59.559+0200 INFO 26064 --- [actor-tcp-nio-1] n.n.r.m.c.R2dbcMigrate : Closing test connection 2020-08-18 11:36:59.569+0200 INFO 26064 --- [actor-tcp-nio-1] n.n.r.m.c.R2dbcMigrate : Successfully got result '42' of test query 2020-08-18 11:36:59.661+0200 INFO 26064 --- [actor-tcp-nio-1] n.n.r.m.c.R2dbcMigrate : By 'Making internal tables' 1 rows updated 2020-08-18 11:36:59.685+0200 INFO 26064 --- [actor-tcp-nio-1] n.n.r.m.c.R2dbcMigrate : By 'Acquiring lock' 1 rows updated 2020-08-18 11:36:59.691+0200 INFO 26064 --- [actor-tcp-nio-1] n.n.r.m.c.R2dbcMigrate : Database version is 0 2020-08-18 11:36:59.701+0200 INFO 26064 --- [actor-tcp-nio-1] n.n.r.m.c.R2dbcMigrate : Applying MigrationInfo{version=1, description='Initial database', splitByLine=false, transactional=true} 2020-08-18 11:36:59.881+0200 INFO 26064 --- [actor-tcp-nio-1] n.n.r.m.c.R2dbcMigrate : By 'MigrationInfo{version=1, description='Initial database', splitByLine=false, transactional=true}' 1 rows updated 2020-08-18 11:36:59.907+0200 WARN 26064 --- [actor-tcp-nio-1] i.r.p.c.ReactorNettyClient : Error: SEVERITY_LOCALIZED=ERROR, SEVERITY_NON_LOCALIZED=ERROR, CODE=42P01, MESSAGE=relation "migrations" does not exist, POSITION=13, FILE=d:\pginstaller_12.auto\postgres.windows-x64\src\backend\parser\parse_relation.c, LINE=1194, ROUTINE=parserOpenTable 2020-08-18 11:36:59.918+0200 ERROR 26064 --- [actor-tcp-nio-1] n.n.r.m.c.R2dbcMigrate : Got error

io.r2dbc.postgresql.ExceptionFactory$PostgresqlBadGrammarException: relation "migrations" does not exist at io.r2dbc.postgresql.ExceptionFactory.createException(ExceptionFactory.java:85) ~[r2dbc-postgresql-0.8.4.RELEASE.jar:0.8.4.RELEASE]`

However, the migrations and migrations_lock tables are created

nkonev commented 4 years ago

@robbydf I think can help if you provide minimal reproducing example with database in docker. Like this.

Without this I can only make assumptions.

It can be error if you create database and switch to it without switch back. Something like

V1__wrong_migration.sql:

create database mydb1;
\c mydb1;
create table t1(mycol text);

V1__correct_migration.sql:

create database mydb1;
\c mydb1;
create table t1(mycol text);
\c db-where-you-from;
nkonev commented 4 years ago

close due to inactivity. feel free to reopen if need