2023-09-12 12:52:01 +07:00
|
|
|
#!/bin/sh
|
|
|
|
cp ./db/csv_seeder/* /tmp/
|
|
|
|
sudo -u postgres psql \
|
|
|
|
-c '\copy users(id,username,password) FROM '"'/tmp/user.csv'"' DELIMITER '"','"' CSV HEADER;' \
|
|
|
|
-c '\copy regions(id, region_name) FROM '"'/tmp/regions.csv'"' DELIMITER '"','"' CSV HEADER;' \
|
|
|
|
-c '\copy provinces(id, province_name, region_id) FROM '"'/tmp/provinsi.csv'"' DELIMITER '"','"' CSV HEADER;' \
|
|
|
|
-c '\copy regencies(id, province_id, regency_name) FROM '"'/tmp/kabupaten.csv'"' DELIMITER '"','"' CSV HEADER;' \
|
2023-09-13 21:42:04 +07:00
|
|
|
-c '\copy locations(id,address,name,submitted_by,thumbnail,regency_id,google_maps_link,approved_by) FROM '"'/tmp/locations.csv'"' DELIMITER '"'#'"' CSV HEADER;' \
|
2023-09-12 12:52:01 +07:00
|
|
|
-d hiling_dev &&
|
|
|
|
sudo -u postgres psql \
|
|
|
|
-c '\copy users(id,username,password) FROM '"'/tmp/user.csv'"' DELIMITER '"','"' CSV HEADER;' \
|
|
|
|
-c '\copy regions(id, region_name) FROM '"'/tmp/regions.csv'"' DELIMITER '"','"' CSV HEADER;' \
|
|
|
|
-c '\copy provinces(id, province_name, region_id) FROM '"'/tmp/provinsi.csv'"' DELIMITER '"','"' CSV HEADER;' \
|
|
|
|
-c '\copy regencies(id, province_id, regency_name) FROM '"'/tmp/kabupaten.csv'"' DELIMITER '"','"' CSV HEADER;' \
|
2023-09-13 21:42:04 +07:00
|
|
|
-c '\copy locations(id,address,name,submitted_by,thumbnail,regency_id,google_maps_link,approved_by) FROM '"'/tmp/locations.csv'"' DELIMITER '"'#'"' CSV HEADER;' \
|
2023-09-12 12:52:01 +07:00
|
|
|
-d hiling_dev_test
|
2023-09-13 21:42:04 +07:00
|
|
|
|
|
|
|
# FIXING SEQUENCES AFTER SEEDING
|
|
|
|
sudo -u postgres psql \
|
|
|
|
-c 'SELECT setval('"'locations_id_seq'"',(SELECT GREATEST(MAX(id)+1,nextval('"'locations_id_seq'"'))-1 FROM locations))' \
|
|
|
|
-d hiling_dev_test &&
|
|
|
|
sudo -u postgres psql \
|
|
|
|
-c 'SELECT setval('"'users_id_seq'"',(SELECT GREATEST(MAX(id)+1,nextval('"'users_id_seq'"'))-1 FROM users))' \
|
|
|
|
-d hiling_dev_test
|
|
|
|
sudo -u postgres psql \
|
|
|
|
-c 'SELECT setval('"'locations_id_seq'"',(SELECT GREATEST(MAX(id)+1,nextval('"'locations_id_seq'"'))-1 FROM locations))' \
|
|
|
|
-d hiling_dev &&
|
|
|
|
sudo -u postgres psql \
|
|
|
|
-c 'SELECT setval('"'users_id_seq'"',(SELECT GREATEST(MAX(id)+1,nextval('"'users_id_seq'"'))-1 FROM users))' \
|
|
|
|
-d hiling_dev
|