From fe60e789d16adecaff7665281b8dad145cfd548f Mon Sep 17 00:00:00 2001 From: Michael Hoennig <michael@hoennig.de> Date: Tue, 9 Apr 2019 10:11:10 +0200 Subject: [PATCH] line-breaks in customer address sanmple data + sample data separated --- .../20190403083735_added_entity_Customer.xml | 16 +--------- .../20190403083736_added_entity_Contact.xml | 16 +--------- ...403083737_added_entity_CustomerContact.xml | 16 +--------- .../changelog/sample-data-Contact.xml | 19 +++++++++++ .../changelog/sample-data-Customer.xml | 32 +++++++++++++++++++ .../changelog/sample-data-CustomerContact.xml | 19 +++++++++++ .../resources/config/liquibase/master.xml | 5 +++ .../liquibase/sample-data/customers.csv | 14 ++++---- 8 files changed, 85 insertions(+), 52 deletions(-) create mode 100644 src/main/resources/config/liquibase/changelog/sample-data-Contact.xml create mode 100644 src/main/resources/config/liquibase/changelog/sample-data-Customer.xml create mode 100644 src/main/resources/config/liquibase/changelog/sample-data-CustomerContact.xml diff --git a/src/main/resources/config/liquibase/changelog/20190403083735_added_entity_Customer.xml b/src/main/resources/config/liquibase/changelog/20190403083735_added_entity_Customer.xml index 4c123a9a..00b9c009 100644 --- a/src/main/resources/config/liquibase/changelog/20190403083735_added_entity_Customer.xml +++ b/src/main/resources/config/liquibase/changelog/20190403083735_added_entity_Customer.xml @@ -1,10 +1,8 @@ <?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"> + xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd"> <property name="now" value="now()" dbms="h2"/> @@ -53,17 +51,5 @@ </createTable> </changeSet> - - <changeSet id="20190402141612-2" author="mhoennig" context="sample-data"> - <loadData encoding="UTF-8" - file="config/liquibase/sample-data/customers.csv" - separator=";" - tableName="customer"> - <column name="id" type="numeric"/> - <column name="jhi_number" type="numeric"/> - <column name="prefix" type="string"/> - </loadData> - </changeSet> - <!-- jhipster-needle-liquibase-add-changeset - JHipster will add changesets here, do not remove--> </databaseChangeLog> diff --git a/src/main/resources/config/liquibase/changelog/20190403083736_added_entity_Contact.xml b/src/main/resources/config/liquibase/changelog/20190403083736_added_entity_Contact.xml index 62bef1eb..6731c5da 100644 --- a/src/main/resources/config/liquibase/changelog/20190403083736_added_entity_Contact.xml +++ b/src/main/resources/config/liquibase/changelog/20190403083736_added_entity_Contact.xml @@ -1,10 +1,8 @@ <?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"> + xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd"> <property name="now" value="now()" dbms="h2"/> @@ -38,17 +36,5 @@ </changeSet> - <changeSet id="20190403083736-2" author="mhoennig" context="sample-data"> - <loadData encoding="UTF-8" - file="config/liquibase/sample-data/contacts.csv" - separator=";" - tableName="contact"> - <column name="id" type="numeric"/> - <column name="first_name" type="string"/> - <column name="last_name" type="string"/> - <column name="email" type="string"/> - </loadData> - </changeSet> - <!-- jhipster-needle-liquibase-add-changeset - JHipster will add changesets here, do not remove--> </databaseChangeLog> diff --git a/src/main/resources/config/liquibase/changelog/20190403083737_added_entity_CustomerContact.xml b/src/main/resources/config/liquibase/changelog/20190403083737_added_entity_CustomerContact.xml index eb08e6ae..332194f3 100644 --- a/src/main/resources/config/liquibase/changelog/20190403083737_added_entity_CustomerContact.xml +++ b/src/main/resources/config/liquibase/changelog/20190403083737_added_entity_CustomerContact.xml @@ -1,10 +1,8 @@ <?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"> + xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd"> <property name="now" value="now()" dbms="h2"/> @@ -38,17 +36,5 @@ </changeSet> - <changeSet id="20190403083737-2" author="mhoennig" context="sample-data"> - <loadData encoding="UTF-8" - file="config/liquibase/sample-data/customer-contacts.csv" - separator=";" - tableName="customer_contact"> - <column name="id" type="numeric"/> - <column name="customer" type="numeric"/> - <column name="role" type="string"/> - <column name="contact" type="numeric"/> - </loadData> - </changeSet> - <!-- jhipster-needle-liquibase-add-changeset - JHipster will add changesets here, do not remove--> </databaseChangeLog> diff --git a/src/main/resources/config/liquibase/changelog/sample-data-Contact.xml b/src/main/resources/config/liquibase/changelog/sample-data-Contact.xml new file mode 100644 index 00000000..4318ff77 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/sample-data-Contact.xml @@ -0,0 +1,19 @@ +<?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-Contact-01" author="mhoennig" context="sample-data"> + <loadData encoding="UTF-8" + file="config/liquibase/sample-data/contacts.csv" + separator=";" + tableName="contact"> + <column name="id" type="numeric"/> + <column name="first_name" type="string"/> + <column name="last_name" type="string"/> + <column name="email" type="string"/> + </loadData> + </changeSet> + +</databaseChangeLog> diff --git a/src/main/resources/config/liquibase/changelog/sample-data-Customer.xml b/src/main/resources/config/liquibase/changelog/sample-data-Customer.xml new file mode 100644 index 00000000..c89e5ada --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/sample-data-Customer.xml @@ -0,0 +1,32 @@ +<?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"> + <column name="id" type="numeric"/> + <column name="jhi_number" type="numeric"/> + <column name="prefix" type="string"/> + <column name="name" type="string"/> + <column name="contractual_address" type="string"/> + </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> diff --git a/src/main/resources/config/liquibase/changelog/sample-data-CustomerContact.xml b/src/main/resources/config/liquibase/changelog/sample-data-CustomerContact.xml new file mode 100644 index 00000000..48488b1c --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/sample-data-CustomerContact.xml @@ -0,0 +1,19 @@ +<?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-CustomerContact-01" author="mhoennig" context="sample-data"> + <loadData encoding="UTF-8" + file="config/liquibase/sample-data/customer-contacts.csv" + separator=";" + tableName="customer_contact"> + <column name="id" type="numeric"/> + <column name="customer" type="numeric"/> + <column name="role" type="string"/> + <column name="contact" type="numeric"/> + </loadData> + </changeSet> + +</databaseChangeLog> diff --git a/src/main/resources/config/liquibase/master.xml b/src/main/resources/config/liquibase/master.xml index 97a01937..ead94099 100644 --- a/src/main/resources/config/liquibase/master.xml +++ b/src/main/resources/config/liquibase/master.xml @@ -17,4 +17,9 @@ <include file="config/liquibase/changelog/20190403083739_added_entity_constraints_Share.xml" relativeToChangelogFile="false"/> <include file="config/liquibase/changelog/20190403083740_added_entity_constraints_Asset.xml" relativeToChangelogFile="false"/> <!-- jhipster-needle-liquibase-add-constraints-changelog - JHipster will add liquibase constraints changelogs here --> + + <include file="config/liquibase/changelog/sample-data-Customer.xml" relativeToChangelogFile="false"/> + <include file="config/liquibase/changelog/sample-data-Contact.xml" relativeToChangelogFile="false"/> + <include file="config/liquibase/changelog/sample-data-CustomerContact.xml" relativeToChangelogFile="false"/> + </databaseChangeLog> diff --git a/src/main/resources/config/liquibase/sample-data/customers.csv b/src/main/resources/config/liquibase/sample-data/customers.csv index 7981d1a8..85c32fcc 100644 --- a/src/main/resources/config/liquibase/sample-data/customers.csv +++ b/src/main/resources/config/liquibase/sample-data/customers.csv @@ -1,7 +1,7 @@ -id;jhi_number;prefix -1;10001;aaa -2;10002;bbb -3;10003;ccc -4;10004;ddd -5;10098;abc -6;10099;bca +id;jhi_number;prefix;name;contractual_address +1;10001;aaa;AAA Corp.;'Ballustrade 13|91334 Erlangen' +2;10002;bbb;BBB GmbH;'Irgendwo 0|11111 Berlin' +3;10003;ccc;CCC AG;'Haus 15|26539 Baltrum' +4;10004;ddd;DDD eG;'Industriestraße 98-102|n22999 Hamburg' +5;10098;abc;ABC OHG;'An der Weide 13|30123 Hannover' +6;10099;bca;Bert Cäsar Adelbert;'Egerstraße 53|44225 Dortmund'