diff --git a/build.gradle b/build.gradle index da0567f7..8cc20b60 100644 --- a/build.gradle +++ b/build.gradle @@ -55,6 +55,9 @@ dependencies { developmentOnly 'org.springframework.boot:spring-boot-devtools' + implementation 'org.flywaydb:flyway-core' + implementation 'org.flywaydb:flyway-database-postgresql' + runtimeOnly 'org.postgresql:postgresql' runtimeOnly 'com.h2database:h2' runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.12.5' @@ -67,6 +70,8 @@ dependencies { testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.security:spring-security-test' + testImplementation 'org.testcontainers:junit-jupiter' + testImplementation 'org.testcontainers:postgresql' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 369ef369..29f38c27 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -20,9 +20,16 @@ spring: redis: host: ${REDIS_HOST} port: ${REDIS_PORT} + flyway: + enabled: true + locations: classpath:db/migration + baseline-on-migrate: ${FLYWAY_BASELINE_ON_MIGRATE:false} + baseline-version: 1 + out-of-order: false + validate-on-migrate: true jpa: hibernate: - ddl-auto: ${DDL_AUTO} + ddl-auto: ${DDL_AUTO:validate} show-sql: ${SHOW_SQL} properties: hibernate: diff --git a/src/main/resources/db/migration/V1__add_substitute_reputation_consent_columns.sql b/src/main/resources/db/migration/V1__add_substitute_reputation_consent_columns.sql deleted file mode 100644 index 2d698092..00000000 --- a/src/main/resources/db/migration/V1__add_substitute_reputation_consent_columns.sql +++ /dev/null @@ -1,12 +0,0 @@ -ALTER TABLE notification_consents - ADD COLUMN IF NOT EXISTS substitute_notification_consent BOOLEAN NOT NULL DEFAULT true, - ADD COLUMN IF NOT EXISTS reputation_notification_consent BOOLEAN NOT NULL DEFAULT true; - -UPDATE notification_consents -SET substitute_notification_consent = notification_consent, - reputation_notification_consent = notification_consent -WHERE notification_consent = false; - -ALTER TABLE notification_consents - ALTER COLUMN substitute_notification_consent DROP DEFAULT, - ALTER COLUMN reputation_notification_consent DROP DEFAULT; diff --git a/src/main/resources/db/migration/V2__add_is_read_column_to_notifications.sql b/src/main/resources/db/migration/V2__add_is_read_column_to_notifications.sql deleted file mode 100644 index e03a4040..00000000 --- a/src/main/resources/db/migration/V2__add_is_read_column_to_notifications.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE notifications - ADD COLUMN IF NOT EXISTS is_read BOOLEAN NOT NULL DEFAULT false; diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml index 49ae696e..a4723dd7 100644 --- a/src/test/resources/application.yml +++ b/src/test/resources/application.yml @@ -16,6 +16,13 @@ spring: redis: host: mock port: 12345 + flyway: + enabled: false + locations: classpath:db/migration + baseline-on-migrate: false + baseline-version: 1 + out-of-order: false + validate-on-migrate: true jpa: database-platform: org.hibernate.dialect.H2Dialect hibernate: