You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
devops: Fix psql \copy paths for Docker and add DOCKER_PSQL flag
- Use relative paths in sample scripts so \copy works both with local
psql and Docker psql (which runs with -w /statbus)
- Add DOCKER_PSQL=1 flag to force Docker psql for testing
- Accept both DEBUG=1 and DEBUG=true for consistency
# Note: Use relative paths for \copy to work both locally and in Docker
42
+
# (Docker psql runs with -w /statbus, so relative paths resolve correctly)
41
43
42
44
# Load legal units with hierarchical identifiers
43
45
# - Uganda units: census_ident (4-level)
44
46
# - Morocco units: judicial_ident (2-level)
45
47
echo"Loading legal units with hierarchical identifiers"
46
-
$WORKSPACE/devops/manage-statbus.sh psql -c "\copy public.import_hierarchical_demo_lu_current_upload(tax_ident,stat_ident,name,birth_date,physical_region_code,physical_country_iso_2,primary_activity_category_code,legal_form_code,sector_code,employees,turnover,data_source_code,census_ident_census,census_ident_region,census_ident_surveyor,census_ident_unit_no,judicial_ident_court,judicial_ident_unit_no) FROM '$WORKSPACE/samples/demo/hierarchical/legal_units_hierarchical_demo.csv' WITH CSV HEADER;"
48
+
$WORKSPACE/devops/manage-statbus.sh psql -c "\copy public.import_hierarchical_demo_lu_current_upload(tax_ident,stat_ident,name,birth_date,physical_region_code,physical_country_iso_2,primary_activity_category_code,legal_form_code,sector_code,employees,turnover,data_source_code,census_ident_census,census_ident_region,census_ident_surveyor,census_ident_unit_no,judicial_ident_court,judicial_ident_unit_no) FROM 'samples/demo/hierarchical/legal_units_hierarchical_demo.csv' WITH CSV HEADER;"
47
49
48
50
# Load formal establishments with hierarchical identifiers
49
51
echo"Loading formal establishments with hierarchical identifiers"
50
-
$WORKSPACE/devops/manage-statbus.sh psql -c "\copy public.import_hierarchical_demo_es_for_lu_current_upload(tax_ident,stat_ident,name,physical_region_code,physical_country_iso_2,primary_activity_category_code,employees,turnover,legal_unit_tax_ident,data_source_code,census_ident_census,census_ident_region,census_ident_surveyor,census_ident_unit_no,judicial_ident_court,judicial_ident_unit_no) FROM '$WORKSPACE/samples/demo/hierarchical/formal_establishments_hierarchical_demo.csv' WITH CSV HEADER;"
52
+
$WORKSPACE/devops/manage-statbus.sh psql -c "\copy public.import_hierarchical_demo_es_for_lu_current_upload(tax_ident,stat_ident,name,physical_region_code,physical_country_iso_2,primary_activity_category_code,employees,turnover,legal_unit_tax_ident,data_source_code,census_ident_census,census_ident_region,census_ident_surveyor,census_ident_unit_no,judicial_ident_court,judicial_ident_unit_no) FROM 'samples/demo/hierarchical/formal_establishments_hierarchical_demo.csv' WITH CSV HEADER;"
51
53
52
54
echo"Checking import job states"
53
55
$WORKSPACE/devops/manage-statbus.sh psql -c "SELECT slug, state FROM public.import_job WHERE slug LIKE 'import_hierarchical_demo_%' ORDER BY slug;"
# Note: Use relative paths for \copy to work both locally and in Docker
38
+
# (Docker psql runs with -w /statbus, so relative paths resolve correctly)
37
39
echo"Loading legal units with source dates demo data"
38
-
$WORKSPACE/devops/manage-statbus.sh psql -c "\copy public.import_demo_lu_wsd_upload(tax_ident,stat_ident,name,valid_from,physical_address_part1,valid_to,postal_address_part1,postal_address_part2,physical_address_part2,physical_postcode,postal_postcode,physical_address_part3,physical_postplace,postal_address_part3,postal_postplace,phone_number,landline,mobile_number,fax_number,web_address,email_address,secondary_activity_category_code,physical_latitude,physical_longitude,physical_altitude,birth_date,physical_region_code,postal_country_iso_2,physical_country_iso_2,primary_activity_category_code,legal_form_code,sector_code,employees,turnover,data_source_code,status_code,unit_size_code) FROM '$WORKSPACE/app/public/demo/legal_units_with_source_dates_demo.csv' WITH CSV HEADER;"
40
+
$WORKSPACE/devops/manage-statbus.sh psql -c "\copy public.import_demo_lu_wsd_upload(tax_ident,stat_ident,name,valid_from,physical_address_part1,valid_to,postal_address_part1,postal_address_part2,physical_address_part2,physical_postcode,postal_postcode,physical_address_part3,physical_postplace,postal_address_part3,postal_postplace,phone_number,landline,mobile_number,fax_number,web_address,email_address,secondary_activity_category_code,physical_latitude,physical_longitude,physical_altitude,birth_date,physical_region_code,postal_country_iso_2,physical_country_iso_2,primary_activity_category_code,legal_form_code,sector_code,employees,turnover,data_source_code,status_code,unit_size_code) FROM 'app/public/demo/legal_units_with_source_dates_demo.csv' WITH CSV HEADER;"
39
41
40
42
# Load formal establishments data
41
43
echo"Loading formal establishments with source dates demo data"
42
-
$WORKSPACE/devops/manage-statbus.sh psql -c "\copy public.import_demo_es_for_lu_wsd_upload(tax_ident,stat_ident,name,physical_region_code,valid_from,valid_to,postal_country_iso_2,physical_country_iso_2,primary_activity_category_code,secondary_activity_category_code,employees,turnover,legal_unit_tax_ident,data_source_code,physical_address_part1,physical_address_part2,physical_address_part3,postal_address_part1,postal_address_part2,postal_address_part3,phone_number,mobile_number,landline,fax_number,web_address,email_address,physical_latitude,physical_longitude,physical_altitude,birth_date,unit_size_code,status_code) FROM '$WORKSPACE/app/public/demo/formal_establishments_units_with_source_dates_demo.csv' WITH CSV HEADER;"
44
+
$WORKSPACE/devops/manage-statbus.sh psql -c "\copy public.import_demo_es_for_lu_wsd_upload(tax_ident,stat_ident,name,physical_region_code,valid_from,valid_to,postal_country_iso_2,physical_country_iso_2,primary_activity_category_code,secondary_activity_category_code,employees,turnover,legal_unit_tax_ident,data_source_code,physical_address_part1,physical_address_part2,physical_address_part3,postal_address_part1,postal_address_part2,postal_address_part3,phone_number,mobile_number,landline,fax_number,web_address,email_address,physical_latitude,physical_longitude,physical_altitude,birth_date,unit_size_code,status_code) FROM 'app/public/demo/formal_establishments_units_with_source_dates_demo.csv' WITH CSV HEADER;"
43
45
44
46
# Load informal establishments data
45
47
echo"Loading informal establishments with source dates demo data"
46
-
$WORKSPACE/devops/manage-statbus.sh psql -c "\copy public.import_demo_es_without_lu_wsd_upload(tax_ident,stat_ident,name,physical_region_code,valid_from,valid_to,physical_country_iso_2,postal_country_iso_2,primary_activity_category_code,secondary_activity_category_code,employees,turnover,data_source_code,physical_address_part1,physical_address_part2,physical_address_part3,postal_address_part1,postal_address_part2,postal_address_part3,phone_number,mobile_number,landline,fax_number,web_address,email_address,unit_size_code,status_code,physical_latitude,physical_longitude,physical_altitude) FROM '$WORKSPACE/app/public/demo/informal_establishments_units_with_source_dates_demo.csv' WITH CSV HEADER;"
48
+
$WORKSPACE/devops/manage-statbus.sh psql -c "\copy public.import_demo_es_without_lu_wsd_upload(tax_ident,stat_ident,name,physical_region_code,valid_from,valid_to,physical_country_iso_2,postal_country_iso_2,primary_activity_category_code,secondary_activity_category_code,employees,turnover,data_source_code,physical_address_part1,physical_address_part2,physical_address_part3,postal_address_part1,postal_address_part2,postal_address_part3,phone_number,mobile_number,landline,fax_number,web_address,email_address,unit_size_code,status_code,physical_latitude,physical_longitude,physical_altitude) FROM 'app/public/demo/informal_establishments_units_with_source_dates_demo.csv' WITH CSV HEADER;"
47
49
48
50
echo"Checking import job states"
49
51
$WORKSPACE/devops/manage-statbus.sh psql -c "SELECT slug, state FROM public.import_job WHERE slug LIKE 'import_demo_%_wsd' ORDER BY slug;"
# Note: Use relative paths for \copy to work both locally and in Docker
37
+
# (Docker psql runs with -w /statbus, so relative paths resolve correctly)
36
38
# Load legal units data
37
39
echo"Loading legal units demo data"
38
-
$WORKSPACE/devops/manage-statbus.sh psql -c "\copy public.import_demo_lu_current_upload(tax_ident,stat_ident,name,birth_date,physical_region_code,physical_country_iso_2,primary_activity_category_code,legal_form_code,sector_code,employees,turnover,data_source_code) FROM '$WORKSPACE/app/public/demo/legal_units_demo.csv' WITH CSV HEADER;"
40
+
$WORKSPACE/devops/manage-statbus.sh psql -c "\copy public.import_demo_lu_current_upload(tax_ident,stat_ident,name,birth_date,physical_region_code,physical_country_iso_2,primary_activity_category_code,legal_form_code,sector_code,employees,turnover,data_source_code) FROM 'app/public/demo/legal_units_demo.csv' WITH CSV HEADER;"
39
41
40
42
# Load formal establishments data
41
43
echo"Loading formal establishments demo data"
42
-
$WORKSPACE/devops/manage-statbus.sh psql -c "\copy public.import_demo_es_for_lu_current_upload(tax_ident,stat_ident,name,physical_region_code,physical_country_iso_2,primary_activity_category_code,employees,turnover,legal_unit_tax_ident,data_source_code) FROM '$WORKSPACE/app/public/demo/formal_establishments_units_demo.csv' WITH CSV HEADER;"
44
+
$WORKSPACE/devops/manage-statbus.sh psql -c "\copy public.import_demo_es_for_lu_current_upload(tax_ident,stat_ident,name,physical_region_code,physical_country_iso_2,primary_activity_category_code,employees,turnover,legal_unit_tax_ident,data_source_code) FROM 'app/public/demo/formal_establishments_units_demo.csv' WITH CSV HEADER;"
43
45
44
46
# Load informal establishments data
45
47
echo"Loading informal establishments demo data"
46
-
$WORKSPACE/devops/manage-statbus.sh psql -c "\copy public.import_demo_es_without_lu_current_upload(tax_ident,stat_ident,name,physical_region_code,physical_country_iso_2,primary_activity_category_code,employees,turnover,data_source_code) FROM '$WORKSPACE/app/public/demo/informal_establishments_units_demo.csv' WITH CSV HEADER;"
48
+
$WORKSPACE/devops/manage-statbus.sh psql -c "\copy public.import_demo_es_without_lu_current_upload(tax_ident,stat_ident,name,physical_region_code,physical_country_iso_2,primary_activity_category_code,employees,turnover,data_source_code) FROM 'app/public/demo/informal_establishments_units_demo.csv' WITH CSV HEADER;"
47
49
48
50
echo"Checking import job states"
49
51
$WORKSPACE/devops/manage-statbus.sh psql -c "SELECT slug, state FROM public.import_job WHERE slug LIKE 'import_demo_%_current' ORDER BY slug;"
Copy file name to clipboardExpand all lines: samples/norway/brreg/brreg-import-selection.sh
+4-2Lines changed: 4 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -71,13 +71,15 @@ FROM def
71
71
ON CONFLICT (slug) DO NOTHING;"
72
72
73
73
echo"Loading data into import tables"
74
+
# Note: Use relative paths for \copy to work both locally and in Docker
75
+
# (Docker psql runs with -w /statbus, so relative paths resolve correctly)
74
76
# Load hovedenhet (legal units) data
75
77
echo"Loading hovedenhet selection data"
76
-
$WORKSPACE/devops/manage-statbus.sh psql -c "\copy public.import_hovedenhet_${YEAR}_selection_upload FROM '$WORKSPACE/samples/norway/legal_unit/enheter-selection.csv' WITH CSV HEADER;"
78
+
$WORKSPACE/devops/manage-statbus.sh psql -c "\copy public.import_hovedenhet_${YEAR}_selection_upload FROM 'samples/norway/legal_unit/enheter-selection.csv' WITH CSV HEADER;"
77
79
78
80
# Load underenhet (establishments) data
79
81
echo"Loading underenhet selection data"
80
-
$WORKSPACE/devops/manage-statbus.sh psql -c "\copy public.import_underenhet_${YEAR}_selection_upload FROM '$WORKSPACE/samples/norway/establishment/underenheter-selection.csv' WITH CSV HEADER;"
82
+
$WORKSPACE/devops/manage-statbus.sh psql -c "\copy public.import_underenhet_${YEAR}_selection_upload FROM 'samples/norway/establishment/underenheter-selection.csv' WITH CSV HEADER;"
81
83
82
84
echo"Checking import job states"
83
85
$WORKSPACE/devops/manage-statbus.sh psql -c "SELECT slug, state FROM public.import_job WHERE slug LIKE '%selection' ORDER BY slug;"
YEARS=$(ls $WORKSPACE/samples/norway/history/*-enheter.csv | sed -E 's/.*\/([0-9]{4})-enheter\.csv/\1/'| sort -u)
38
+
# Note: Use relative paths for \copy to work both locally and in Docker
39
+
# (Docker psql runs with -w /statbus, so relative paths resolve correctly)
40
+
YEARS=$(ls samples/norway/history/*-enheter.csv | sed -E 's/.*\/([0-9]{4})-enheter\.csv/\1/'| sort -u)
39
41
40
42
echo"Creating import jobs for each year"
41
43
forYEARin$YEARS;do
@@ -76,11 +78,11 @@ for YEAR in $YEARS; do
76
78
77
79
# Load hovedenhet (legal units) data
78
80
echo"Loading hovedenhet data for $YEAR"
79
-
$WORKSPACE/devops/manage-statbus.sh psql -c "\copy public.import_hovedenhet_${YEAR}_history_upload FROM '$WORKSPACE/samples/norway/history/${YEAR}-enheter.csv' WITH CSV HEADER;"
81
+
$WORKSPACE/devops/manage-statbus.sh psql -c "\copy public.import_hovedenhet_${YEAR}_history_upload FROM 'samples/norway/history/${YEAR}-enheter.csv' WITH CSV HEADER;"
80
82
81
83
# Load underenhet (establishments) data
82
84
echo"Loading underenhet data for $YEAR"
83
-
$WORKSPACE/devops/manage-statbus.sh psql -c "\copy public.import_underenhet_${YEAR}_history_upload FROM '$WORKSPACE/samples/norway/history/${YEAR}-underenheter.csv' WITH CSV HEADER;"
85
+
$WORKSPACE/devops/manage-statbus.sh psql -c "\copy public.import_underenhet_${YEAR}_history_upload FROM 'samples/norway/history/${YEAR}-underenheter.csv' WITH CSV HEADER;"
YEARS=$(ls $WORKSPACE/samples/norway/small-history/*-enheter.csv | sed -E 's/.*\/([0-9]{4})-enheter\.csv/\1/'| sort -u)
38
+
# Note: Use relative paths for \copy to work both locally and in Docker
39
+
# (Docker psql runs with -w /statbus, so relative paths resolve correctly)
40
+
YEARS=$(ls samples/norway/small-history/*-enheter.csv | sed -E 's/.*\/([0-9]{4})-enheter\.csv/\1/'| sort -u)
39
41
40
42
echo"Creating import jobs for each year"
41
43
forYEARin$YEARS;do
@@ -76,11 +78,11 @@ for YEAR in $YEARS; do
76
78
77
79
# Load hovedenhet (legal units) data
78
80
echo"Loading hovedenhet data for $YEAR"
79
-
$WORKSPACE/devops/manage-statbus.sh psql -c "\copy public.import_hovedenhet_${YEAR}_small_history_upload FROM '$WORKSPACE/samples/norway/small-history/${YEAR}-enheter.csv' WITH CSV HEADER;"
81
+
$WORKSPACE/devops/manage-statbus.sh psql -c "\copy public.import_hovedenhet_${YEAR}_small_history_upload FROM 'samples/norway/small-history/${YEAR}-enheter.csv' WITH CSV HEADER;"
80
82
81
83
# Load underenhet (establishments) data
82
84
echo"Loading underenhet data for $YEAR"
83
-
$WORKSPACE/devops/manage-statbus.sh psql -c "\copy public.import_underenhet_${YEAR}_small_history_upload FROM '$WORKSPACE/samples/norway/small-history/${YEAR}-underenheter.csv' WITH CSV HEADER;"
85
+
$WORKSPACE/devops/manage-statbus.sh psql -c "\copy public.import_underenhet_${YEAR}_small_history_upload FROM 'samples/norway/small-history/${YEAR}-underenheter.csv' WITH CSV HEADER;"
84
86
done
85
87
86
88
#echo "Running worker processing to process import jobs"
0 commit comments