add tags seeder and fix sequence

This commit is contained in:
nochill 2023-09-20 12:30:57 +07:00
parent a5138ed6a5
commit 902247b6ed
2 changed files with 22 additions and 1 deletions

7
db/csv_seeder/tags.csv Normal file
View File

@ -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
1 id name submitted_by target_id tags_type
2 1 makanan jos 1 1 location
3 2 masjid 1 2 location
4 3 islam 1 2 location
5 4 mancing mania mantab 1 10 location
6 5 olahraga 1 6 location
7 6 hotel 1 7 location

View File

@ -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 &&
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