diff --git a/db/csv_seeder/tags.csv b/db/csv_seeder/tags.csv new file mode 100644 index 0000000..cd87b63 --- /dev/null +++ b/db/csv_seeder/tags.csv @@ -0,0 +1,7 @@ +id,name,submitted_by,target_id,tags_type +1,makanan jos,1,1,location +2,masjid,1,2,location +3,islam,1,2,location +4,mancing mania mantab,1,10,location +5,olahraga,1,6,location +6,hotel,1,7,location \ No newline at end of file diff --git a/import_csv.sh b/import_csv.sh index 5444616..368d96a 100755 --- a/import_csv.sh +++ b/import_csv.sh @@ -8,6 +8,7 @@ sudo -u postgres psql \ -c '\copy locations(id,address,name,submitted_by,thumbnail,regency_id,google_maps_link,approved_by) FROM '"'/tmp/locations.csv'"' DELIMITER '"'#'"' CSV HEADER;' \ -c '\copy reviews(id,submitted_by,is_from_critic,comments,score,is_hided,location_id) FROM '"'/tmp/reviews.csv'"' DELIMITER '"'#'"' CSV HEADER;' \ -c '\copy images(id,image_url,uploaded_by,image_type,image_of) FROM '"'/tmp/images.csv'"' DELIMITER '"'#'"' CSV HEADER;' \ + -c '\copy tags(id,name,submitted_by,target_id,tags_type) FROM '"'/tmp/tags.csv'"' DELIMITER '"','"' CSV HEADER;' \ -d hiling_dev && sudo -u postgres psql \ -c '\copy users(id,username,password) FROM '"'/tmp/user.csv'"' DELIMITER '"','"' CSV HEADER;' \ @@ -17,6 +18,7 @@ sudo -u postgres psql \ -c '\copy locations(id,address,name,submitted_by,thumbnail,regency_id,google_maps_link,approved_by) FROM '"'/tmp/locations.csv'"' DELIMITER '"'#'"' CSV HEADER;' \ -c '\copy reviews(id,submitted_by,is_from_critic,comments,score,is_hided,location_id) FROM '"'/tmp/reviews.csv'"' DELIMITER '"'#'"' CSV HEADER;' \ -c '\copy images(id,image_url,uploaded_by,image_type,image_of) FROM '"'/tmp/images.csv'"' DELIMITER '"'#'"' CSV HEADER;' \ + -c '\copy tags(id,name,submitted_by,target_id,tags_type) FROM '"'/tmp/tags.csv'"' DELIMITER '"','"' CSV HEADER;' \ -d hiling_dev_test # FIXING SEQUENCES AFTER SEEDING @@ -29,6 +31,12 @@ sudo -u postgres psql \ sudo -u postgres psql \ -c 'SELECT setval('"'reviews_id_seq'"',(SELECT GREATEST(MAX(id)+1,nextval('"'reviews_id_seq'"'))-1 FROM reviews))' \ -d hiling_dev_test && +sudo -u postgres psql \ + -c 'SELECT setval('"'images_id_seq'"',(SELECT GREATEST(MAX(id)+1,nextval('"'images_id_seq'"'))-1 FROM images))' \ + -d hiling_dev_test && +sudo -u postgres psql \ + -c 'SELECT setval('"'tags_id_seq'"',(SELECT GREATEST(MAX(id)+1,nextval('"'tags_id_seq'"'))-1 FROM tags))' \ + -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 && @@ -37,4 +45,10 @@ sudo -u postgres psql \ -d hiling_dev && sudo -u postgres psql \ -c 'SELECT setval('"'reviews_id_seq'"',(SELECT GREATEST(MAX(id)+1,nextval('"'reviews_id_seq'"'))-1 FROM reviews))' \ - -d hiling_dev + -d hiling_dev && + sudo -u postgres psql \ + -c 'SELECT setval('"'images_id_seq'"',(SELECT GREATEST(MAX(id)+1,nextval('"'images_id_seq'"'))-1 FROM images))' \ + -d hiling_dev && +sudo -u postgres psql \ + -c 'SELECT setval('"'tags_id_seq'"',(SELECT GREATEST(MAX(id)+1,nextval('"'tags_id_seq'"'))-1 FROM tags))' \ + -d hiling_dev \ No newline at end of file