2022-09-08 18:10:49.187  INFO 4935 --- [           main] o.f.core.internal.command.DbValidate     : Successfully validated 5 migrations (execution time 00:00.084s)
2022-09-08 18:10:49.231  INFO 4935 --- [           main] o.f.c.i.s.JdbcTableSchemaHistory         : Creating Schema History table "PUBLIC"."flyway_schema_history" ...
2022-09-08 18:10:49.334  INFO 4935 --- [           main] o.f.core.internal.command.DbMigrate      : Current version of schema "PUBLIC": << Empty Schema >>
2022-09-08 18:10:49.368  INFO 4935 --- [           main] o.f.core.internal.command.DbMigrate      : Migrating schema "PUBLIC" to version "1 - init ddl"
2022-09-08 18:10:49.390 ERROR 4935 --- [           main] o.f.core.internal.command.DbMigrate      : Migration of schema "PUBLIC" to version "1 - init ddl" failed! Please restore backups and roll back database and code!
2022-09-08 18:10:49.428  WARN 4935 --- [           main] o.s.w.c.s.GenericWebApplicationContext   : 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 V1__init_ddl.sql failed
---------------------------------
SQL State  : 42001
Error Code : 42001
Message    : Syntax error in SQL statement "CREATE TABLE USER (
                             ID CHAR(32) NOT NULL,
                             NICKNAME VARCHAR(50) NOT NULL,
                             SOCIAL_ID VARCHAR(50) NOT NULL,
                             SOCIAL_TYPE VARCHAR(20) NOT NULL,
                             CREATED_AT DATETIME(6) NOT NULL,
                             UPDATED_AT DATETIME(6) NOT NULL,
                             PRIMARY KEY (ID)
) ENGINE=[*]INNODB DEFAULT CHARSET=UTF8MB4 COLLATE=UTF8MB4_0900_AI_CI"; expected "identifier"; SQL statement:

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 V1__init_ddl.sql failed
Message    : Syntax error in SQL statement "CREATE TABLE USER (
                             ID CHAR(32) NOT NULL,
                             NICKNAME VARCHAR(50) NOT NULL,
                             SOCIAL_ID VARCHAR(50) NOT NULL,
                             SOCIAL_TYPE VARCHAR(20) NOT NULL,
                             CREATED_AT DATETIME(6) NOT NULL,
                             UPDATED_AT DATETIME(6) NOT NULL,
                             PRIMARY KEY (ID)
) ENGINE=[*]INNODB DEFAULT CHARSET=UTF8MB4 COLLATE=UTF8MB4_0900_AI_CI"; expected "identifier"; SQL statement:

yml 에 있는 flyway 랑 상관없이 동작 - docker 인가?

implementation ‘org.flywaydb:flyway-core:7.10.0’ 해당 코드를 빼면 실행 됨.

즉 해당 코드가 프로젝트에 어떻게 동작하는지 이해할 필요가 있음.

##Database Seeding

Database seeding is populating a database with an initial set of data. It’s common to load seed data such as initial user accounts or dummy data upon initial setup of an application.

Flyway

Flyway is an open-source database migration tool

simplicity and convention 을 중요하게 여기는 database migration tool 이다.

기본 명령어

Migrate, Clean, Info, Validate, Undo, Baseline and Repair.

Migration

Flyway 에서는 데이터베이스의 모든 변경사항을 Migration 이라고 한다.

Spring Boot jars include metadata files that provide details of all supported configuration properties. The files are designed to let IDE developers offer contextual help and “code completion” as users are working with application.properties or application.yml files.

The majority of the metadata file is generated automatically at compile time by processing all items annotated with @ConfigurationProperties. However, it is possible to write part of the metadata manually for corner cases or more advanced use cases.

Updated:

Leave a comment