From 31bc67855aac8aa648424aadabbd42a01b939677 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Tue, 2 Apr 2024 10:55:15 +0000 Subject: [PATCH] feat : using liquibase instead of flyway for sql versioning --- aws-secretmanager-project/pom.xml | 4 ++-- .../main/java/com/example/awsspring/entities/Customer.java | 7 +------ .../main/resources/db/changelog/db.changelog-master.yaml | 5 +++++ .../db/changelog/migration/V1_create_customers_table.sql | 7 +++++++ .../src/main/resources/db/migration/h2/V1__01_init.sql | 0 .../db/migration/h2/V2__create_customers_table.sql | 7 ------- .../main/resources/db/migration/postgresql/V1__01_init.sql | 0 .../db/migration/postgresql/V2__create_customers_table.sql | 7 ------- 8 files changed, 15 insertions(+), 22 deletions(-) create mode 100644 aws-secretmanager-project/src/main/resources/db/changelog/db.changelog-master.yaml create mode 100644 aws-secretmanager-project/src/main/resources/db/changelog/migration/V1_create_customers_table.sql delete mode 100644 aws-secretmanager-project/src/main/resources/db/migration/h2/V1__01_init.sql delete mode 100644 aws-secretmanager-project/src/main/resources/db/migration/h2/V2__create_customers_table.sql delete mode 100644 aws-secretmanager-project/src/main/resources/db/migration/postgresql/V1__01_init.sql delete mode 100644 aws-secretmanager-project/src/main/resources/db/migration/postgresql/V2__create_customers_table.sql diff --git a/aws-secretmanager-project/pom.xml b/aws-secretmanager-project/pom.xml index f1cb9976..a5f7b806 100644 --- a/aws-secretmanager-project/pom.xml +++ b/aws-secretmanager-project/pom.xml @@ -80,8 +80,8 @@ runtime - org.flywaydb - flyway-core + org.liquibase + liquibase-core org.springdoc diff --git a/aws-secretmanager-project/src/main/java/com/example/awsspring/entities/Customer.java b/aws-secretmanager-project/src/main/java/com/example/awsspring/entities/Customer.java index 0962a377..eb3037cf 100644 --- a/aws-secretmanager-project/src/main/java/com/example/awsspring/entities/Customer.java +++ b/aws-secretmanager-project/src/main/java/com/example/awsspring/entities/Customer.java @@ -5,7 +5,6 @@ import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; -import jakarta.persistence.SequenceGenerator; import jakarta.persistence.Table; import jakarta.validation.constraints.NotEmpty; import lombok.AllArgsConstructor; @@ -22,11 +21,7 @@ public class Customer { @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "customer_id_generator") - @SequenceGenerator( - name = "customer_id_generator", - sequenceName = "customer_id_seq", - allocationSize = 100) + @GeneratedValue(strategy = GenerationType.SEQUENCE) private Long id; @Column(nullable = false) diff --git a/aws-secretmanager-project/src/main/resources/db/changelog/db.changelog-master.yaml b/aws-secretmanager-project/src/main/resources/db/changelog/db.changelog-master.yaml new file mode 100644 index 00000000..01de1e94 --- /dev/null +++ b/aws-secretmanager-project/src/main/resources/db/changelog/db.changelog-master.yaml @@ -0,0 +1,5 @@ +databaseChangeLog: + - includeAll: + path: /migration + relativeToChangelogFile: true + errorsOnMissingFile: true diff --git a/aws-secretmanager-project/src/main/resources/db/changelog/migration/V1_create_customers_table.sql b/aws-secretmanager-project/src/main/resources/db/changelog/migration/V1_create_customers_table.sql new file mode 100644 index 00000000..3256c847 --- /dev/null +++ b/aws-secretmanager-project/src/main/resources/db/changelog/migration/V1_create_customers_table.sql @@ -0,0 +1,7 @@ +create sequence customers_seq start with 1 increment by 50; + +create table customers ( + id bigint DEFAULT nextval('customers_seq') not null, + text varchar(1024) not null, + primary key (id) +); diff --git a/aws-secretmanager-project/src/main/resources/db/migration/h2/V1__01_init.sql b/aws-secretmanager-project/src/main/resources/db/migration/h2/V1__01_init.sql deleted file mode 100644 index e69de29b..00000000 diff --git a/aws-secretmanager-project/src/main/resources/db/migration/h2/V2__create_customers_table.sql b/aws-secretmanager-project/src/main/resources/db/migration/h2/V2__create_customers_table.sql deleted file mode 100644 index c58a0ea2..00000000 --- a/aws-secretmanager-project/src/main/resources/db/migration/h2/V2__create_customers_table.sql +++ /dev/null @@ -1,7 +0,0 @@ -create sequence customer_id_seq start with 1 increment by 100; - -create table customers ( - id bigint DEFAULT nextval('customer_id_seq') not null, - text varchar(1024) not null, - primary key (id) -); diff --git a/aws-secretmanager-project/src/main/resources/db/migration/postgresql/V1__01_init.sql b/aws-secretmanager-project/src/main/resources/db/migration/postgresql/V1__01_init.sql deleted file mode 100644 index e69de29b..00000000 diff --git a/aws-secretmanager-project/src/main/resources/db/migration/postgresql/V2__create_customers_table.sql b/aws-secretmanager-project/src/main/resources/db/migration/postgresql/V2__create_customers_table.sql deleted file mode 100644 index c58a0ea2..00000000 --- a/aws-secretmanager-project/src/main/resources/db/migration/postgresql/V2__create_customers_table.sql +++ /dev/null @@ -1,7 +0,0 @@ -create sequence customer_id_seq start with 1 increment by 100; - -create table customers ( - id bigint DEFAULT nextval('customer_id_seq') not null, - text varchar(1024) not null, - primary key (id) -);