user13417868
user13417868

Reputation: 11

null value in column "installed_on" violates not-null constraint

We created a new database by coping from an older flyway managed database. (flyway version table also copied over)

Running flyway against this new database produces the following flyway error

Apr 24 19:00:19 ip-xx flyway: Unable to insert row for version '184' in Schema History table "public"."flyway_schema_history" Apr 24 19:00:19 ip--xx flyway: ----------------------------------------------------------------------------------------------- Apr 24 19:00:19 ip--xx flyway: SQL State : 23502 Apr 24 19:00:19 ip--xx flyway: Error Code : 0 Apr 24 19:00:19 ip--xx flyway: Message : ERROR: null value in column "installed_on" violates not-null constraint

Upvotes: 1

Views: 1656

Answers (2)

Martin Espinach
Martin Espinach

Reputation: 31

In my case, the error occurred while upgrading from flyway version 5.x to 6.4.3. The definition of installed_on column of the flyway_schema_history table (at least in PostgreSQL) has changed from:

installed_on timestamp NOT NULL;

to:

installed_on timestamp NOT NULL DEFAULT now ()

Adding DEFAULT now() on the existing table has fixed the problem.

Upvotes: 2

Julia Hayward
Julia Hayward

Reputation: 2155

Which version of Flyway are you using, and has it changed when you moved database? Which database are you using?

If you could create an issue at github.com/flyway/flyway/issues with reproduction steps then the team will investigate for you.

Upvotes: 0

Related Questions