shares sample data and some cleanup

This commit is contained in:
Michael Hoennig 2019-05-02 11:17:22 +02:00
parent 7f358cc7fe
commit 84f1abf0b0
7 changed files with 59 additions and 55 deletions

View File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
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">
<changeSet id="sample-data-Customer-01" author="mhoennig" context="sample-data">
<loadData encoding="UTF-8"
file="config/liquibase/sample-data/customers.csv"
separator=";"
quotchar="'"
tableName="customer">
</loadData>
<!-- Liquibase CSV files can contain linebreaks just as real linebreaks, but which
make the CSV files hard to read. Therefore I've encoded linebreaks as '|' and
replace these after import with '\n'. -->
<sql>
UPDATE customer SET contractual_address = REPLACE(contractual_address, '|', STRINGDECODE('\n'));
</sql>
<rollback>
DELETE FROM customer;
</rollback>
</changeSet>
</databaseChangeLog>

View File

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
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">
<changeSet id="sample-data-Membership-01" author="mhoennig" context="sample-data">
<loadData encoding="UTF-8"
file="config/liquibase/sample-data/memberships.csv"
separator=";"
tableName="membership">
</loadData>
<!-- Liquibase CSV files can contain linebreaks just as real linebreaks, but which
make the CSV files hard to read. Therefore I've encoded linebreaks as '|' and
replace these after import with '\n'. -->
<sql>
UPDATE membership SET remark = REPLACE(remark, '|', STRINGDECODE('\n'));
</sql>
<rollback>
DELETE FROM membership;
</rollback>
</changeSet>
</databaseChangeLog>

View File

@ -22,5 +22,6 @@
<!-- sample data -->
<include file="config/liquibase/sample-data/customers.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/sample-data/memberships.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/sample-data/shares.xml" relativeToChangelogFile="false"/>
</databaseChangeLog>

View File

@ -19,7 +19,13 @@
</changeSet>
<changeSet id="20190403083736-3" author="mhoennig" context="sample-data">
<sql>UPDATE customer SET contractual_address = replace(contractual_address, '|', '\n')</sql>
<sql>
UPDATE customer SET contractual_address = replace(contractual_address, '|', '\n')
</sql>
<rollback>
DELETE FROM customer;
</rollback>
</changeSet>
</databaseChangeLog>

View File

@ -19,7 +19,13 @@
</changeSet>
<changeSet id="20190502100700-2" author="mhoennig" context="sample-data">
<sql>UPDATE membership SET remark = replace(remark, '|', '\n')</sql>
<sql>
UPDATE membership SET remark = replace(remark, '|', '\n')
</sql>
<rollback>
DELETE FROM membership;
</rollback>
</changeSet>
</databaseChangeLog>

View File

@ -0,0 +1,13 @@
id;membership_id;document_date;value_date;action;quantity;remark
1;1;2001-04-10;2001-04-11;SUBSCRIPTION;16;some|multiline|remark
2;1;2007-08-09;2007-12-31;CANCELLATION;16;another remark
3;2;2017-01-15;2017-01-17;SUBSCRIPTION;8;became a member again
4;2;2017-01-15;2017-01-17;SUBSCRIPTION;1;just writing something
5;3;2003-05-11;2003-05-18;SUBSCRIPTION;4;some comment
6;3;2003-05-15;2003-05-30;CANCELLATION;4;cancelled membership
7;4;2017-05-15;2017-05-17;SUBSCRIPTION;16;
8;5;2011-08-18;2011-09-01;SUBSCRIPTION;10;
9;5;2012-12-15;2013-01-01;SUBSCRIPTION;20;signed more shares
10;5;2017-11-22;2018-01-01;CANCELLATION;25;cancelled most of their shares
1 id membership_id document_date value_date action quantity remark
2 1 1 2001-04-10 2001-04-11 SUBSCRIPTION 16 some|multiline|remark
3 2 1 2007-08-09 2007-12-31 CANCELLATION 16 another remark
4 3 2 2017-01-15 2017-01-17 SUBSCRIPTION 8 became a member again
5 4 2 2017-01-15 2017-01-17 SUBSCRIPTION 1 just writing something
6 5 3 2003-05-11 2003-05-18 SUBSCRIPTION 4 some comment
7 6 3 2003-05-15 2003-05-30 CANCELLATION 4 cancelled membership
8 7 4 2017-05-15 2017-05-17 SUBSCRIPTION 16
9 8 5 2011-08-18 2011-09-01 SUBSCRIPTION 10
10 9 5 2012-12-15 2013-01-01 SUBSCRIPTION 20 signed more shares
11 10 5 2017-11-22 2018-01-01 CANCELLATION 25 cancelled most of their shares

View File

@ -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="20190502111400-1" author="mhoennig" context="sample-data">
<loadData encoding="UTF-8"
file="config/liquibase/sample-data/shares.csv"
separator=";"
tableName="share">
</loadData>
</changeSet>
<changeSet id="20190502111400-2" author="mhoennig" context="sample-data">
<sql>
UPDATE share SET remark = replace(remark, '|', '\n')
</sql>
<rollback>
DELETE FROM share;
</rollback>
</changeSet>
</databaseChangeLog>