From 6706187d67afb793f7250d73914564cddf94a568 Mon Sep 17 00:00:00 2001 From: Austin Rooks Date: Fri, 24 Nov 2023 13:27:22 -0600 Subject: [PATCH] remove scripts for justfile --- .../basic_data => basic_data}/fish_recipe.csv | 0 .../basic_data => basic_data}/fish_types.csv | 0 {scripts/basic_data => basic_data}/fishs.csv | 0 .../basic_data => basic_data}/recipes.csv | 0 justfile | 8 +-- scripts/init_db.sh | 51 ------------------- scripts/populate_db.sh | 14 ----- 7 files changed, 4 insertions(+), 69 deletions(-) rename {scripts/basic_data => basic_data}/fish_recipe.csv (100%) rename {scripts/basic_data => basic_data}/fish_types.csv (100%) rename {scripts/basic_data => basic_data}/fishs.csv (100%) rename {scripts/basic_data => basic_data}/recipes.csv (100%) delete mode 100755 scripts/init_db.sh delete mode 100755 scripts/populate_db.sh diff --git a/scripts/basic_data/fish_recipe.csv b/basic_data/fish_recipe.csv similarity index 100% rename from scripts/basic_data/fish_recipe.csv rename to basic_data/fish_recipe.csv diff --git a/scripts/basic_data/fish_types.csv b/basic_data/fish_types.csv similarity index 100% rename from scripts/basic_data/fish_types.csv rename to basic_data/fish_types.csv diff --git a/scripts/basic_data/fishs.csv b/basic_data/fishs.csv similarity index 100% rename from scripts/basic_data/fishs.csv rename to basic_data/fishs.csv diff --git a/scripts/basic_data/recipes.csv b/basic_data/recipes.csv similarity index 100% rename from scripts/basic_data/recipes.csv rename to basic_data/recipes.csv diff --git a/justfile b/justfile index c5911f8..cb7557b 100644 --- a/justfile +++ b/justfile @@ -67,10 +67,10 @@ populate: exit 1 fi - psql "postgres://postgres:password@localhost:5432/fish" -c "\copy fish_type from "scripts/basic_data/fish_types.csv" DELIMITER ',' CSV HEADER;" - psql "postgres://postgres:password@localhost:5432/fish" -c "\copy fish from "scripts/basic_data/fishs.csv" DELIMITER ',' CSV HEADER;" - psql "postgres://postgres:password@localhost:5432/fish" -c "\copy recipe from "scripts/basic_data/recipes.csv" DELIMITER ',' CSV HEADER;" - psql "postgres://postgres:password@localhost:5432/fish" -c "\copy fishtype_recipe from "scripts/basic_data/fish_recipe.csv" DELIMITER ',' CSV HEADER;" + psql "postgres://postgres:password@localhost:5432/fish" -c "\copy fish_type from "basic_data/fish_types.csv" DELIMITER ',' CSV HEADER;" + psql "postgres://postgres:password@localhost:5432/fish" -c "\copy fish from "basic_data/fishs.csv" DELIMITER ',' CSV HEADER;" + psql "postgres://postgres:password@localhost:5432/fish" -c "\copy recipe from "basic_data/recipes.csv" DELIMITER ',' CSV HEADER;" + psql "postgres://postgres:password@localhost:5432/fish" -c "\copy fishtype_recipe from "basic_data/fish_recipe.csv" DELIMITER ',' CSV HEADER;" # Initialize an instance of the database. diff --git a/scripts/init_db.sh b/scripts/init_db.sh deleted file mode 100755 index 3f03fb1..0000000 --- a/scripts/init_db.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env bash -set -x -set -eo pipefail - -if ! [ -x "$(command -v psql)" ]; then - echo >&2 "Error: psql is not installed." - exit 1 -fi - -if ! [ -x "$(command -v sqlx)" ]; then - echo >&2 "Error: sqlx is not installed." - echo >&2 "Use:" - echo >&2 " cargo install --version=0.5.7 sqlx-cli --no-default-features --features postgres" - echo >&2 "to install it." - exit 1 -fi - -DB_USER=${POSTGRES_USER:=postgres} -DB_PASSWORD="${POSTGRES_PASSWORD:=password}" -DB_NAME="${POSTGRES_DB:=fish}" -DB_PORT="${POSTGRES_PORT:=5432}" - -if [[ -z "${SKIP_DOCKER}" ]] -then - docker run \ - -e POSTGRES_USER=${DB_USER} \ - -e POSTGRES_PASSWORD=${DB_PASSWORD} \ - -e POSTGRES_DB=${DB_NAME} \ - -p "${DB_PORT}":5432 \ - -d postgres \ - postgres -N 1000 -fi - -# Keep pinging Postgres until it's ready to accept commands -export PGPASSWORD="${DB_PASSWORD}" -until psql -h "localhost" -U "${DB_USER}" -p "${DB_PORT}" -d "postgres" -c '\q'; do - >&2 echo "Postgres is still unavailable - sleeping" - sleep 1 -done - ->&2 echo "Postgres is up and running on port ${DB_PORT}!" - -export DATABASE_URL=postgres://${DB_USER}:${DB_PASSWORD}@localhost:${DB_PORT}/${DB_NAME} -sqlx database create -sqlx migrate run - -# sleep 5 -# psql -c "COPY fish_type from './basic_data/fish_type.csv' delimiter ',' CSV HEADER;" -# psql -c "COPY fish from './basic_data/fishs.csv' delimiter ',' CSV HEADER;" -# psql -c "COPY recipe from './basic_data/recipe.csv' delimiter ',' CSV HEADER;" -# psql -c "COPY fishtype_recipe from './basic_data/ft_recipe.csv' delimiter ',' CSV HEADER;" diff --git a/scripts/populate_db.sh b/scripts/populate_db.sh deleted file mode 100755 index ef9cf9e..0000000 --- a/scripts/populate_db.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash -# After creating the db, run this from the project's root to populate it with data. -set -x -set -eo pipefail - -if ! [ -x "$(command -v psql)" ]; then - echo >&2 "Error: psql is not installed." - exit 1 -fi - -psql "postgres://postgres:password@localhost:5432/fish" -c "\copy fish_type from "scripts/basic_data/fish_types.csv" DELIMITER ',' CSV HEADER;" -psql "postgres://postgres:password@localhost:5432/fish" -c "\copy fish from "scripts/basic_data/fishs.csv" DELIMITER ',' CSV HEADER;" -psql "postgres://postgres:password@localhost:5432/fish" -c "\copy recipe from "scripts/basic_data/recipes.csv" DELIMITER ',' CSV HEADER;" -psql "postgres://postgres:password@localhost:5432/fish" -c "\copy fishtype_recipe from "scripts/basic_data/fish_recipe.csv" DELIMITER ',' CSV HEADER;"