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

Flyway-error: Could ninja get an Flyway-upgrade so that postgresql 12 gets supported? #684

Open
rrarrarra opened this issue Jun 25, 2020 · 1 comment

Comments

@rrarrarra
Copy link

Hi,

i am currently migrating my ninja-project to run with:

  • Ubuntu Server 20.04 LTS
  • Postgres (PostgreSQL) 12.2 (Ubuntu 12.2-4)
  • ninja framework 6.6.1

but I am getting an error,

2020-06-25-20:34:27.493 [main] INFO  o.f.c.i.license.VersionPrinter - Flyway Community Edition 5.2.4 by Boxfuse
2020-06-25-20:34:27.555 [main] INFO  o.f.c.i.database.DatabaseFactory - Database: jdbc:postgresql://localhost:5432/XXX (PostgreSQL 12.2)
2020-06-25-20:34:27.570 [main] WARN  o.f.c.i.database.base.Database - Flyway upgrade recommended: PostgreSQL 12.2 is newer than this version of Flyway and support has not been tested.
ninja.lifecycle.FailedStartException: org.flywaydb.core.internal.exception.FlywaySqlException: 
Unable to clean schema "public"
-------------------------------
SQL State  : 42703
Error Code : 0
Message    : ERROR: column pg_proc.proisagg does not exist
  Hint: Perhaps you meant to reference the column "pg_proc.prolang".
  Position: 54

please refer to:


The flyway-documentation says, that the current version supports posgtresql version 12:
https://flywaydb.org/documentation/database/postgresql

<!-- https://mvnrepository.com/artifact/org.flywaydb/flyway-core -->
<dependency>
    <groupId>org.flywaydb</groupId>
    <artifactId>flyway-core</artifactId>
    <version>6.4.4</version>
</dependency>

Question:

  • Is it possible that ninja gets an upgrade for that in the near future?
  • If not, what is the recommended way of letting me manually upgrade the flyway version regarding to work fine with the ninjaframework?

Thanks in advance and best regards :-)

@davidgiga1993
Copy link

You can easily replace flyway with a different version:

  1. Add your flyway version as dependency (and exclude the default one
  2. Add your own migration engine:
public class FlywayMigration implements MigrationEngine
{
	private final NinjaProperties ninjaProperties;

	@Inject
	public FlywayMigration(NinjaProperties ninjaProperties)
	{
		this.ninjaProperties = ninjaProperties;
	}

	@Override
	public void migrate()
	{
		String connectionUrl = this.ninjaProperties.getOrDie("db.connection.url");
		String connectionUsername = this.ninjaProperties.getOrDie("db.connection.username");
		String connectionPassword = this.ninjaProperties.getOrDie("db.connection.password");

		Properties properties = new Properties();
		Flyway flyway = Flyway.configure()
				.configuration(properties)
				.dataSource(connectionUrl, connectionUsername, connectionPassword)
				.load();

		if (this.ninjaProperties.getBooleanWithDefault("ninja.migration.drop", this.ninjaProperties.isTest()))
		{
			flyway.clean();
		}
		if (!ninjaProperties.isTest())
		{
			// Test starts with a clean DB anyways
			flyway.baseline();
		}
		try
		{
			flyway.migrate();
		}
		catch (FlywaySqlScriptException e)
		{
			e.printStackTrace();
			throw e;
		}
	}
}
  1. Add migration.engine.implementation=conf.FlywayMigration to your application.conf

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

No branches or pull requests

2 participants