From d43876a01b4a3dff9666f190aa0c191b90446889 Mon Sep 17 00:00:00 2001 From: Robert van Dijk Date: Sat, 26 Oct 2024 20:19:32 +0200 Subject: [PATCH] Add database migration --- .../V202410026__Add_administration_costs.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/main/java/db/migration/V202410026__Add_administration_costs.java diff --git a/src/main/java/db/migration/V202410026__Add_administration_costs.java b/src/main/java/db/migration/V202410026__Add_administration_costs.java new file mode 100644 index 00000000..f348ed45 --- /dev/null +++ b/src/main/java/db/migration/V202410026__Add_administration_costs.java @@ -0,0 +1,27 @@ +package db.migration; + +import org.flywaydb.core.api.migration.BaseJavaMigration; +import org.flywaydb.core.api.migration.Context; + +import java.sql.Statement; + + +/** + * DB migration which adds Transaction cost field. + */ +public class V202410026__Add_administration_costs extends BaseJavaMigration { + + /** + * Executes this migration. The execution will automatically take place within a transaction, when the underlying + * database supports it. + * + * @param context of type Context + * @throws Exception when something is wrong + */ + public void migrate(Context context) throws Exception { + try (Statement select = context.getConnection().createStatement()) { + select.execute("ALTER TABLE public.orders ADD COLUMN administrationCosts DOUBLE PRECISION NOT NULL DEFAULT 0"); + } + } + +}