HSDB Dump Script

Script that is a able to dump HSDB (legacy) data to csv files.
Dump of "office" module data already implemented.
This commit is contained in:
Michael Hierweck 2024-01-09 12:28:57 +01:00
parent 5280527eae
commit 1f278819c3
1 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,41 @@
dump() {
sql="copy ($1) to stdout with csv header delimiter ';' quote '\"'"
psql --host ${host} --port ${port} --user ${username} --command "${sql}" ${dbname} >"${file}"
dump "select bp_id, member_id, member_code, member_since, member_until, member_role, author_contract, nondisc_contract, free, exempt_vat, indicator_vat, uid_vat
from business_partner
order by bp_id" \
dump "select contact_id, bp_id, salut, first_name, last_name, title, firma, co, street, zipcode, city, country, phone_private, phone_office, phone_mobile, fax, email, array_to_string(array_agg(role), ',') as roles
from contact
left join contactrole_ref using(contact_id)
group by contact_id
order by contact_id" \
dump "select sepa_mandat_id, bp_id, bank_customer, bank_name, bank_iban, bank_bic, mandat_ref, mandat_signed, mandat_since, mandat_until, mandat_used
from sepa_mandat
order by sepa_mandat_id" \
dump "select member_asset_id, bp_id, date, action, amount, comment
from member_asset
order by member_asset_id" \
dump "select member_share_id, bp_id, date, action, quantity, comment
from member_share
order by member_share_id" \