luthor/DB/import.sh

33 lines
5.4 KiB
Bash
Executable File

#!/usr/bin/env bash
scp knox:leg.tar.zip /home/tanshu/Programming/luthor/DB/csv
cd /home/tanshu/Programming/luthor/DB/csv
tar xvf leg.tar.zip
docker run -it --link postgres:db --rm --env PGPASSWORD="123456" postgres:alpine bash -c 'psql -h db -U postgres -c "drop database luthor"'
docker run -it --link postgres:db --rm --env PGPASSWORD="123456" postgres:alpine bash -c 'psql -h db -U postgres -c "create database luthor"'
docker run -it --link postgres:db --rm --env PGPASSWORD="123456" postgres:alpine bash -c 'psql -h db -U postgres luthor -c "CREATE EXTENSION btree_gist;"'
cd /home/tanshu/Programming/luthor/luthor
alembic upgrade 74058d75b7a0
docker run -it -v /home/tanshu/Programming/luthor/DB/csv:/mnt --link postgres:db --rm --env PGPASSWORD="123456" postgres:alpine bash -c 'psql -h db -U postgres luthor -c "\copy acts(old_id, name) from /mnt/a-acts.csv"'
sed -i 's/\x0//g' /home/tanshu/Programming/luthor/DB/csv/b-advocates.csv
docker run -it -v /home/tanshu/Programming/luthor/DB/csv:/mnt --link postgres:db --rm --env PGPASSWORD="123456" postgres:alpine bash -c 'psql -h db -U postgres luthor -c "\copy advocates(old_id, name, mobile, landline, address, email) from /mnt/b-advocates.csv"'
sed -i 's/\x0//g' /home/tanshu/Programming/luthor/DB/csv/c-case-types.csv
docker run -it -v /home/tanshu/Programming/luthor/DB/csv:/mnt --link postgres:db --rm --env PGPASSWORD="123456" postgres:alpine bash -c 'psql -h db -U postgres luthor -c "\copy case_types(old_id, name) from /mnt/c-case-types.csv"'
sed -i 's/\x0//g' /home/tanshu/Programming/luthor/DB/csv/d-court-statuses.csv
docker run -it -v /home/tanshu/Programming/luthor/DB/csv:/mnt --link postgres:db --rm --env PGPASSWORD="123456" postgres:alpine bash -c 'psql -h db -U postgres luthor -c "\copy court_statuses(old_id, name) from /mnt/d-court-statuses.csv"'
docker run -it -v /home/tanshu/Programming/luthor/DB/csv:/mnt --link postgres:db --rm --env PGPASSWORD="123456" postgres:alpine bash -c 'psql -h db -U postgres luthor -c "\copy courts(old_id, name) from /mnt/e-courts.csv"'
sed -i 's/\x0//g' /home/tanshu/Programming/luthor/DB/csv/f-departments.csv
docker run -it -v /home/tanshu/Programming/luthor/DB/csv:/mnt --link postgres:db --rm --env PGPASSWORD="123456" postgres:alpine bash -c 'psql -h db -U postgres luthor -c "\copy departments(old_id, name) from /mnt/f-departments.csv"'
docker run -it -v /home/tanshu/Programming/luthor/DB/csv:/mnt --link postgres:db --rm --env PGPASSWORD="123456" postgres:alpine bash -c 'psql -h db -U postgres luthor -c "\copy natures(old_id, name) from /mnt/g-natures.csv"'
docker run -it -v /home/tanshu/Programming/luthor/DB/csv:/mnt --link postgres:db --rm --env PGPASSWORD="123456" postgres:alpine bash -c 'psql -h db -U postgres luthor -c "\copy office_statuses(old_id, name) from /mnt/h-office-statuses.csv"'
docker run -it -v /home/tanshu/Programming/luthor/DB/csv:/mnt --link postgres:db --rm --env PGPASSWORD="123456" postgres:alpine bash -c 'psql -h db -U postgres luthor -c "\copy permissions(old_id, name) from /mnt/i-permissions.csv"'
docker run -it -v /home/tanshu/Programming/luthor/DB/csv:/mnt --link postgres:db --rm --env PGPASSWORD="123456" postgres:alpine bash -c 'psql -h db -U postgres luthor -c "\copy users(old_id, name, password, locked_out) from /mnt/j-users.csv"'
sed -i 's/\x0//g' /home/tanshu/Programming/luthor/DB/csv/k-offices.csv
docker run -it -v /home/tanshu/Programming/luthor/DB/csv:/mnt --link postgres:db --rm --env PGPASSWORD="123456" postgres:alpine bash -c 'psql -h db -U postgres luthor -c "\copy offices(old_id, old_department_id, name, address, email) from /mnt/k-offices.csv"'
docker run -it -v /home/tanshu/Programming/luthor/DB/csv:/mnt --link postgres:db --rm --env PGPASSWORD="123456" postgres:alpine bash -c 'psql -h db -U postgres luthor -c "\copy role_permissions(old_user_id, old_permission_id) from /mnt/l-user-roles.csv"'
sed -i 's/\x0//g' /home/tanshu/Programming/luthor/DB/csv/m-cases.csv
docker run -it -v /home/tanshu/Programming/luthor/DB/csv:/mnt --link postgres:db --rm --env PGPASSWORD="123456" postgres:alpine bash -c 'psql -h db -U postgres luthor -c "\copy cases(old_id, old_office_file_number, office_file_number, court_case_number, year, title, docket_number, receipt_date, limitation_date, filing_date, appear_on_behalf_of, question_of_law, aor_name, opposing_council_aor, lower_court_case_number, date_of_impugned_judgement, brief_description, remarks, slp_counter, contact_detail, case_connected_with, old_court_id, old_department_id, old_office_id, old_case_type_id, old_act_id, old_nature_id, old_court_status_id, old_office_status_id, opposing_council_detail, bunch_cases) from /mnt/m-cases.csv with delimiter E'\''\t'\'' null as '\'''\''"'
#docker run -it -v /home/tanshu/Programming/luthor/DB/csv:/mnt --link postgres:db --rm --env PGPASSWORD="123456" postgres:alpine bash -c 'psql -h db -U postgres luthor -c "\copy contacts(old_id, old_office_id, old_department_id, brief, next_hearing_date, court_status_id, court_number, item_number) from /mnt/n-contact-persons.csv"'
sed -i 's/\x0//g' /home/tanshu/Programming/luthor/DB/csv/o-hearings.csv
docker run -it -v /home/tanshu/Programming/luthor/DB/csv:/mnt --link postgres:db --rm --env PGPASSWORD="123456" postgres:alpine bash -c 'psql -h db -U postgres luthor -c "\copy hearings(old_id, old_case_id, bench, proceedings, next_hearing_date, old_court_status_id, court_number, item_number) from /mnt/o-hearings.csv with delimiter E'\''\t'\'' null as '\'''\''"'
alembic upgrade 87a06eaadd34