You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
alfio fails when at booting up pointing to a database that may have a table in their schema, even if you try to add the properties or the environment properties that should make Flyway take this into account.
Just to add, some times it is mandatory to respect the actual status of the database and depending on the cloud provider, some databases will have their own extensions installed in order to provide some features, like geospatial support. Example for PostgreSQL here and here
To Reproduce
Steps to reproduce the behavior:
Deploy alf.io in a database with some tables in the same schema
Setup the properties that should make Flyway respect the actual database structure via adding the properties flyway.baselineOnMigrate=true or defining the environment variable FLYWAY_BASELINE_ON_MIGRATE=true
Boot up alf.io
You will see an stacktrace like this: 09:58:47.927 [main] WARN org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'adminReservationManager' defined in URL [jar:file:/.../alfio-boot.war!/WEB-INF/classes!/alfio/manager/AdminReservationManager.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'eventManager' defined in URL [jar:file:/.../alfio-boot.war!/WEB-INF/classes!/alfio/manager/EventManager.class]: Unsatisfied dependency expressed through constructor parameter 14; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'migrator' defined in alfio.config.DataSourceConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'migrator' threw exception; nested exception is org.flywaydb.core.api.FlywayException: Found non-empty schema(s) "public" without metadata table! Use baseline() or set baselineOnMigrate to true to initialize the metadata table.
Expected behavior
What I should expect is to respect the actual DB and add the corresponding tables required to boot alfio
Screenshots
N/A Desktop (please complete the following information):
N/A Smartphone (please complete the following information):
N/A
Additional context
Branch 1.x-maintenance
I think I found a solution for this, and I'll lunch a MR in order set the proper Flyway environment variables in order to skip this behaviour.
PS: There is another issue after solving this which is that the schema_version table will be created on the 1st bootup but incorrectly. This is what you will see the next stacktrace after fixing the previous error:
21:52:54.384 [main] ERROR org.flywaydb.core.internal.command.DbMigrate - Migration of schema "public" to version 2 - ADD CONFIRMATION TS failed! Changes successfully rolled back.
2018-12-01T22:52:54+01:00 21:52:54.390 [main] WARN org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'adminReservationManager' defined in URL [jar:file:/.../alfio-boot.war!/WEB-INF/classes!/alfio/manager/AdminReservationManager.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'eventManager' defined in URL [jar:file:/.../alfio-boot.war!/WEB-INF/classes!/alfio/manager/EventManager.class]: Unsatisfied dependency expressed through constructor parameter 14; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'migrator' defined in alfio.config.DataSourceConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'migrator' threw exception; nested exception is org.flywaydb.core.internal.command.DbMigrate$FlywayMigrateSqlException:
2018-12-01T22:52:54+01:00 Migration V2__ADD_CONFIRMATION_TS.sql failed
2018-12-01T22:52:54+01:00 --------------------------------------------
2018-12-01T22:52:54+01:00 SQL State : 42P01
2018-12-01T22:52:54+01:00 Error Code : 0
2018-12-01T22:52:54+01:00 Message : ERROR: relation "tickets_reservation" does not exist
2018-12-01T22:52:54+01:00 Location : alfio/db/PGSQL/V2__ADD_CONFIRMATION_TS.sql (/..../alfio-boot.war!/WEB-INF/classes!/alfio/db/PGSQL/V2__ADD_CONFIRMATION_TS.sql)
2018-12-01T22:52:54+01:00 Line : 18
2018-12-01T22:52:54+01:00 Statement : alter table tickets_reservation add column confirmation_ts timestamp with time zone
2018-12-01T22:52:54+01:00 21:52:54.433 [main] ERROR org.springframework.boot.SpringApplication - Application startup failed
But if you connect to the database, delete the existing rows of this table and restarts alf.io, finally you will get the system up & running ;-)
The text was updated successfully, but these errors were encountered:
Describe the bug
alfio fails when at booting up pointing to a database that may have a table in their schema, even if you try to add the properties or the environment properties that should make Flyway take this into account.
Just to add, some times it is mandatory to respect the actual status of the database and depending on the cloud provider, some databases will have their own extensions installed in order to provide some features, like geospatial support. Example for PostgreSQL here and here
To Reproduce
Steps to reproduce the behavior:
flyway.baselineOnMigrate=true
or defining the environment variableFLYWAY_BASELINE_ON_MIGRATE=true
09:58:47.927 [main] WARN org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'adminReservationManager' defined in URL [jar:file:/.../alfio-boot.war!/WEB-INF/classes!/alfio/manager/AdminReservationManager.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'eventManager' defined in URL [jar:file:/.../alfio-boot.war!/WEB-INF/classes!/alfio/manager/EventManager.class]: Unsatisfied dependency expressed through constructor parameter 14; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'migrator' defined in alfio.config.DataSourceConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'migrator' threw exception; nested exception is org.flywaydb.core.api.FlywayException: Found non-empty schema(s) "public" without metadata table! Use baseline() or set baselineOnMigrate to true to initialize the metadata table.
Expected behavior
What I should expect is to respect the actual DB and add the corresponding tables required to boot alfio
Screenshots
N/A
Desktop (please complete the following information):
N/A
Smartphone (please complete the following information):
N/A
Additional context
Branch
1.x-maintenance
I think I found a solution for this, and I'll lunch a MR in order set the proper Flyway environment variables in order to skip this behaviour.
PS: There is another issue after solving this which is that the
schema_version
table will be created on the 1st bootup but incorrectly. This is what you will see the next stacktrace after fixing the previous error:But if you connect to the database, delete the existing rows of this table and restarts alf.io, finally you will get the system up & running ;-)
The text was updated successfully, but these errors were encountered: