jokull/Justfile

47 lines
1.5 KiB
Makefile
Raw Permalink Normal View History

2024-04-11 09:35:52 +00:00
# other
cert_path := ""
prod_db_url := ""
# repo settings
tools_dir := justfile_directory() / ".tools"
gtfs_importer_dir := tools_dir / "gtfs-sql-importer"
gtfs_importer_repo := "https://github.com/fitnr/gtfs-sql-importer"
# data urls
straeto_schedule_data := "https://opendata.straeto.is/data/gtfs/gtfs.zip"
straeto_dl_file := tools_dir / "straeto-gtfs.zip"
# prod postgres settings
export PGSSLROOTCERT := justfile_directory() / "prod-supabase.cer"
export PGUSER := "postgres.yexfstvjfxhursmqcqcu"
export PGPASSWORD := env_var("PGPASSWORD")
export PGHOST := "aws-0-eu-central-1.pooler.supabase.com"
export PGSSLMODE := "verify-full"
export PGDATABASE := "postgres"
@ensure_tool_dir:
mkdir -p {{ tools_dir }}
@clone_gtfs_sql_importer: ensure_tool_dir
test -d {{ gtfs_importer_dir }} || git clone {{ gtfs_importer_repo }} {{ gtfs_importer_dir }}
cd {{ gtfs_importer_dir }} && \
git fetch origin master > /dev/null 2>&1 && \
git reset --hard origin/master > /dev/null 2>&1
clean:
rm -f {{ straeto_dl_file }}
add_indices_prod: clone_gtfs_sql_importer
cd {{ gtfs_importer_dir }} && make add_indices
import_schedules_prod: clone_gtfs_sql_importer
cd {{ gtfs_importer_dir }} && make init > /dev/null 2>&1 || true
test -e {{ straeto_dl_file }} || \
wget {{ straeto_schedule_data }} -O {{ straeto_dl_file }}
cd {{ gtfs_importer_dir }} && make drop_notnull
cd {{ gtfs_importer_dir }} && make drop_constraints
cd {{ gtfs_importer_dir }} && make -j load GTFS="{{ straeto_dl_file }}"
cd {{ gtfs_importer_dir }} && make add_constraints