<commit_before>#!/usr/bin/env bash

set -e

CLI_ERR_MSG="Postgres CLI tools not available (psql). Using Postgres.app, look
at http://postgresapp.com/documentation/cli-tools.html. Aborting."
hash psql 2>/dev/null || { echo >&2 $CLI_ERR_MSG ; exit 1; }

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

cd $DIR


# Provision

## Create lumen role
psql -c "CREATE ROLE lumen WITH PASSWORD 'password' CREATEDB LOGIN;"

## Create lumen dbs
psql -f $DIR/helpers/create-lumen.sql

## Create extensions for dbs
psql -d lumen -f $DIR/helpers/create-extensions.sql
psql -d test_lumen -f $DIR/helpers/create-extensions.sql

## Create tenants dbs
psql -f $DIR/helpers/create-tenants.sql

## Create extensions for dbs
psql -d lumen_tenant_1 -f $DIR/helpers/create-extensions.sql
psql -d lumen_tenant_2 -f $DIR/helpers/create-extensions.sql
psql -d test_lumen_tenant_1 -f $DIR/helpers/create-extensions.sql
psql -d test_lumen_tenant_2 -f $DIR/helpers/create-extensions.sql

sh -c "$DIR/helpers/import_csv.sh $DIR/helpers/liberia.csv | psql -d lumen_tenant_1";
echo "SELECT AddGeometryColumn('liberia', 'geom', 4326, 'point', 2);" \
     "UPDATE liberia SET geom = " \
     "  ST_SetSRID(ST_MakePoint(longitude::float8, latitude::float8), 4326)" \
     " WHERE longitude != '' and latitude != '';" \
     "CREATE INDEX ON liberia USING GIST (geom);" \
     | psql --set ON_ERROR_STOP=1 -d lumen_tenant_1

echo "ALTER TABLE liberia OWNER TO lumen;" | psql -d lumen_tenant_1
echo "ALTER TABLE spatial_ref_sys OWNER TO lumen;" | psql -d lumen_tenant_1

echo ""
echo "----------"
echo "Done!"<commit_msg>checking that the postgres image is rebuilt<commit_after>#!/usr/bin/env bash

set -e

CLI_ERR_MSG="Postgres CLI tools not available (psql). Using Postgres.app, look
at http://postgresapp.com/documentation/cli-tools.html. Aborting."
hash psql 2>/dev/null || { echo >&2 $CLI_ERR_MSG ; exit 1; }

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

cd $DIR


# Provision

## Create lumen role
psql -c "CREATE ROLE lumen WITH PASSWORD 'password' CREATEDB LOGIN;"

## Create lumen dbs
psql -f $DIR/helpers/create-lumen.sql

## Create extensions for dbs
psql -d lumen -f $DIR/helpers/create-extensions.sql
psql -d test_lumen -f $DIR/helpers/create-extensions.sql

## Create tenants dbs
psql -f $DIR/helpers/create-tenants.sql

## Create extensions for dbs
psql -d lumen_tenant_1 -f $DIR/helpers/create-extensions.sql
psql -d lumen_tenant_2 -f $DIR/helpers/create-extensions.sql
psql -d test_lumen_tenant_1 -f $DIR/helpers/create-extensions.sql
psql -d test_lumen_tenant_2 -f $DIR/helpers/create-extensions.sql

sh -c "$DIR/helpers/import_csv.sh $DIR/helpers/liberia.csv | psql -d lumen_tenant_1";
echo "SELECT AddGeometryColumn('liberia', 'geom', 4326, 'point', 2);" \
     "UPDATE liberia SET geom = " \
     "  ST_SetSRID(ST_MakePoint(longitude::float8, latitude::float8), 4326)" \
     " WHERE longitude != '' and latitude != '';" \
     "CREATE INDEX ON liberia USING GIST (geom);" \
     | psql --set ON_ERROR_STOP=1 -d lumen_tenant_1

echo "ALTER TABLE liberia OWNER TO lumen;" | psql -d lumen_tenant_1
echo "ALTER TABLE spatial_ref_sys OWNER TO lumen;" | psql -d lumen_tenant_1

echo ""
echo "----------"
echo "Done!!"
{'fraction_non_alphanumeric': 0.1420578178427106, 'fraction_numerical': 0.014920733602735468, 'mean_word_length': 3.973724884080371, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4909626', 'n_tokens_mistral': 1229, 'n_tokens_neox': 1184, 'n_words': 317}