2
respostas

Problema na migration da tabela RESPOSTA

O Flyway acusa problema na tabela resposta mas não enxergo onde está a incoerência.

repositório: https://github.com/apontes77/kotlin-springboot/tree/main/src/main/resources/db/migration

2 respostas

Oi Rafael,

Posta aqui o erro que acontece ao inicializar a aplicação

022-08-17 20:49:51.501  WARN 12885 --- [  restartedMain] o.f.c.internal.database.base.Database    : Flyway upgrade recommended: H2 2.1.214 is newer than this version of Flyway and support has not been tested. The latest supported version of H2 is 2.1.210.
2022-08-17 20:49:51.538  INFO 12885 --- [  restartedMain] o.f.core.internal.command.DbValidate     : Successfully validated 4 migrations (execution time 00:00.020s)
2022-08-17 20:49:51.546  INFO 12885 --- [  restartedMain] o.f.c.i.s.JdbcTableSchemaHistory         : Creating Schema History table "PUBLIC"."flyway_schema_history" ...
2022-08-17 20:49:51.585  INFO 12885 --- [  restartedMain] o.f.core.internal.command.DbMigrate      : Current version of schema "PUBLIC": << Empty Schema >>
2022-08-17 20:49:51.594  INFO 12885 --- [  restartedMain] o.f.core.internal.command.DbMigrate      : Migrating schema "PUBLIC" to version "1 - create table curso"
2022-08-17 20:49:51.614  INFO 12885 --- [  restartedMain] o.f.core.internal.command.DbMigrate      : Migrating schema "PUBLIC" to version "2 - create table usuario"
2022-08-17 20:49:51.626  INFO 12885 --- [  restartedMain] o.f.core.internal.command.DbMigrate      : Migrating schema "PUBLIC" to version "3 - create table topico"
2022-08-17 20:49:51.647  INFO 12885 --- [  restartedMain] o.f.core.internal.command.DbMigrate      : Migrating schema "PUBLIC" to version "4 - create table resposta"
2022-08-17 20:49:51.652 ERROR 12885 --- [  restartedMain] o.f.core.internal.command.DbMigrate      : Migration of schema "PUBLIC" to version "4 - create table resposta" failed! Please restore backups and roll back database and code!
2022-08-17 20:49:51.661  WARN 12885 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.internal.command.DbMigrate$FlywayMigrateException: Migration V4__create_table_resposta.sql failed
----------------------------------------------
SQL State  : 42001
Error Code : 42001
Message    : Syntax error in SQL statement "create table resposta(\000a    id bigint not null auto_increment,\000a    mensagem varchar(300) not null,\000a    data_criacao datetime not null,\000a    topico_id bigint not null,\000a    autor_id bigint not null,\000a    solucao int[*](1) not null,\000a    primary key(id),\000a    foreign key(topico_id) references topico(id),\000a    foreign key(autor_id) references usuario(id)\000a)"; expected "ARRAY, INVISIBLE, VISIBLE, NOT NULL, NULL, AS, DEFAULT, GENERATED, ON UPDATE, NOT NULL, NULL, AUTO_INCREMENT, DEFAULT ON NULL, NULL_TO_DEFAULT, SEQUENCE, SELECTIVITY, COMMENT, CONSTRAINT, COMMENT, PRIMARY KEY, UNIQUE, NOT NULL, NULL, CHECK, REFERENCES, AUTO_INCREMENT, ,, )"; SQL statement:
create table resposta(
    id bigint not null auto_increment,
    mensagem varchar(300) not null,
    data_criacao datetime not null,
    topico_id bigint not null,
    autor_id bigint not null,
    solucao int(1) not null,
    primary key(id),
    foreign key(topico_id) references topico(id),
    foreign key(autor_id) references usuario(id)
) [42001-214]
Location   : db/migration/V4__create_table_resposta.sql (/home/alexandre/projetos/forum/target/classes/db/migration/V4__create_table_resposta.sql)
Line       : 1
Statement  : create table resposta(
    id bigint not null auto_increment,
    mensagem varchar(300) not null,
    data_criacao datetime not null,
    topico_id bigint not null,
    autor_id bigint not null,
    solucao int(1) not null,
    primary key(id),
    foreign key(topico_id) references topico(id),
    foreign key(autor_id) references usuario(id)
)