From 20b9d2f1059688c663a0f1987f7906ccb9aec9d1 Mon Sep 17 00:00:00 2001
From: Michael Hoennig <michael@hoennig.de>
Date: Fri, 3 May 2019 20:21:07 +0200
Subject: [PATCH] #131 sample-data for sepamandate

---
 .../resources/config/liquibase/master.xml     |  1 +
 .../liquibase/sample-data/sepamandates.csv    |  6 ++++
 .../liquibase/sample-data/sepamandates.xml    | 31 +++++++++++++++++++
 3 files changed, 38 insertions(+)
 create mode 100644 src/main/resources/config/liquibase/sample-data/sepamandates.csv
 create mode 100644 src/main/resources/config/liquibase/sample-data/sepamandates.xml

diff --git a/src/main/resources/config/liquibase/master.xml b/src/main/resources/config/liquibase/master.xml
index e4d99de6..36848208 100644
--- a/src/main/resources/config/liquibase/master.xml
+++ b/src/main/resources/config/liquibase/master.xml
@@ -24,5 +24,6 @@
     <include file="config/liquibase/sample-data/memberships.xml" relativeToChangelogFile="false"/>
     <include file="config/liquibase/sample-data/shares.xml" relativeToChangelogFile="false"/>
     <include file="config/liquibase/sample-data/assets.xml" relativeToChangelogFile="false"/>
+    <include file="config/liquibase/sample-data/sepamandates.xml" relativeToChangelogFile="false"/>
 
 </databaseChangeLog>
diff --git a/src/main/resources/config/liquibase/sample-data/sepamandates.csv b/src/main/resources/config/liquibase/sample-data/sepamandates.csv
new file mode 100644
index 00000000..2698cc95
--- /dev/null
+++ b/src/main/resources/config/liquibase/sample-data/sepamandates.csv
@@ -0,0 +1,6 @@
+id;customer_id;reference;iban;bic;granting_document_date;revokation_document_date;valid_from_date;valid_until_date;last_used_date;remark
+1;1;DKXIDEHAC01;DE94500105172859877827;REF02039402;2018-01-15;null;2018-01-16;null;2019-04-09;a remark|over two lines
+2;2;JKUIDEBIS00;DE56500105172321139153;REF2834823W;2017-06-03;2019-01-15;2017-06-04;2019-01-31;2019-01-10;for the old bank account
+3;2;JUZTDEVER03;DE56500105172321139153;REF2834823W;2019-01-15;null;2019-02-01;null;2019-04-09;for the new bank account
+4;3;CKIZDESiX98;DE24500105175933769123;REF23984928;2016-09-13;2018-11-20;2016-09-13;2018-12-31;2018-12-09;membership cancelled
+5;5;ZUIJDEVOR12;DE92500105174781793571;REF23882384;2016-12-03;null;2016-12-03;null;2019-04-09;null
diff --git a/src/main/resources/config/liquibase/sample-data/sepamandates.xml b/src/main/resources/config/liquibase/sample-data/sepamandates.xml
new file mode 100644
index 00000000..1e75c9ea
--- /dev/null
+++ b/src/main/resources/config/liquibase/sample-data/sepamandates.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<databaseChangeLog
+    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
+    xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd
+                        http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
+    <property name="now" value="now()" dbms="h2"/>
+    <property name="now" value="current_timestamp" dbms="postgresql"/>
+    <property name="floatType" value="float4" dbms="postgresql, h2"/>
+    <property name="floatType" value="float" dbms="mysql, oracle, mssql"/>
+
+    <changeSet id="20190503152800-1" author="mhoennig" context="sample-data">
+        <loadData encoding="UTF-8"
+                  file="config/liquibase/sample-data/sepamandates.csv"
+                  separator=";"
+                  tableName="sepa_mandate">
+        </loadData>
+    </changeSet>
+
+    <changeSet id="20190503152800-2" author="mhoennig" context="sample-data">
+        <sql>
+            UPDATE sepa_mandate SET remark = replace(remark, '|', STRINGDECODE('\n'))
+        </sql>
+
+        <rollback>
+            DELETE FROM sepa_mandate;
+        </rollback>
+    </changeSet>
+
+</databaseChangeLog>