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 cannot create schema table on Galera cluster (MariaDB) #1293

Closed
erindru opened this issue Apr 26, 2016 · 1 comment · Fixed by #1294
Closed

Flyway cannot create schema table on Galera cluster (MariaDB) #1293

erindru opened this issue Apr 26, 2016 · 1 comment · Fixed by #1294

Comments

@erindru
Copy link
Contributor

erindru commented Apr 26, 2016

What version of Flyway are you using?

4.0

What database are you using (type & version)?

MariaDB 10.1.13. Note: this issue is caused by setting innodb_force_primary_key=1 which is required for the Galera cluster to work properly. You dont need to set up a Galera cluster to reproduce this issue, you can do it by setting that property on a normal MariaDB instance.

What operating system are you using?

Mac OSX and Linux

What did you do?

Ran Flyway.migrate() and observed the following error:

2016.04.26 12:09:22.980 INFO  [main]  o.f.c.i.u.l.slf4j.Slf4jLog.info (Slf4jLog.java:44) - Creating Metadata table: `sentinel_audit`.`schema_version`
2016.04.26 12:09:23.006 WARN  [main]  o.f.c.i.u.l.slf4j.Slf4jLog.warn (Slf4jLog.java:48) - DB: This table type requires a primary key (SQL State: 42000 - Error Code: 1173)
2016.04.26 12:09:23.009 WARN  [main]  o.s.c.s.AbstractApplicationContext.refresh (AbstractApplicationContext.java:545) - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayConfig': Injection of autowired dependencies failed; nested exception is org.flywaydb.core.internal.dbsupport.FlywaySqlScriptException: 
Script failed
-------------
SQL State  : 42000
Error Code : 1173
Message    : This table type requires a primary key
Line       : 17
Statement  : CREATE TABLE `sentinel_audit`.`schema_version` (
    `installed_rank` INT NOT NULL,
    `version` VARCHAR(50),
    `description` VARCHAR(200) NOT NULL,
    `type` VARCHAR(20) NOT NULL,
    `script` VARCHAR(1000) NOT NULL,
    `checksum` INT,
    `installed_by` VARCHAR(100) NOT NULL,
    `installed_on` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `execution_time` INT NOT NULL,
    `success` BOOL NOT NULL
) ENGINE=InnoDB
What did you expect to see?

The schema_version table created successfully

What did you see instead?

A This table type requires a primary key error returned from the database server

Since you use DB-specific SQL for each database, the following script can be updated to create a primary key at the same time as the table instead of directly afterwards: https://github.com/flyway/flyway/blob/master/flyway-core/src/main/resources/org/flywaydb/core/internal/dbsupport/mysql/createMetaDataTable.sql

I will submit a pull request for this.

erindru pushed a commit to erindru/flyway that referenced this issue Apr 26, 2016
…o that Flyway can work on servers with 'innodb_force_primary_key' enabled. Fixes flyway#1293
axelfontaine pushed a commit that referenced this issue May 5, 2016
…o that Flyway can work on servers with 'innodb_force_primary_key' enabled. Fixes #1293 (#1294)
axelfontaine pushed a commit to flyway/flywaydb.org that referenced this issue May 5, 2016
@axelfontaine axelfontaine added this to the Flyway 4.0.1 milestone May 5, 2016
@axelfontaine
Copy link
Contributor

Thanks Erin! PR merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants