From ac1ff7aff8ceb2b031fc325b5047d9a9791f37c7 Mon Sep 17 00:00:00 2001 From: jamesrwarren Date: Mon, 25 Nov 2024 13:37:21 +0000 Subject: [PATCH] try with v14 instead --- api/app/scripts/reindex_and_stats/reindex.sql | 1 + .../scripts/reindex_and_stats/statistics.sql | 1 + api/app/scripts/reset_db_fixtures.sh | 1 + api/app/scripts/setup_reindex.sh | 45 +++++++++++++++++++ terraform/environment/terraform.tfvars.json | 6 +-- 5 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 api/app/scripts/reindex_and_stats/reindex.sql create mode 100644 api/app/scripts/reindex_and_stats/statistics.sql create mode 100755 api/app/scripts/setup_reindex.sh diff --git a/api/app/scripts/reindex_and_stats/reindex.sql b/api/app/scripts/reindex_and_stats/reindex.sql new file mode 100644 index 0000000000..2a14176fd9 --- /dev/null +++ b/api/app/scripts/reindex_and_stats/reindex.sql @@ -0,0 +1 @@ +REINDEX DATABASE api; diff --git a/api/app/scripts/reindex_and_stats/statistics.sql b/api/app/scripts/reindex_and_stats/statistics.sql new file mode 100644 index 0000000000..7797f4c59a --- /dev/null +++ b/api/app/scripts/reindex_and_stats/statistics.sql @@ -0,0 +1 @@ +ANALYZE; diff --git a/api/app/scripts/reset_db_fixtures.sh b/api/app/scripts/reset_db_fixtures.sh index 103ff3dbb9..1a3c975540 100644 --- a/api/app/scripts/reset_db_fixtures.sh +++ b/api/app/scripts/reset_db_fixtures.sh @@ -14,3 +14,4 @@ fi # Run the custom SQL query setup script ./scripts/setup_custom_sql_query.sh ./scripts/setup_readonly_sql_query.sh +./scripts/setup_reindex.sh diff --git a/api/app/scripts/setup_reindex.sh b/api/app/scripts/setup_reindex.sh new file mode 100755 index 0000000000..43a1e5a643 --- /dev/null +++ b/api/app/scripts/setup_reindex.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +# Directory where SQL scripts are stored +SQL_DIR="./scripts/reindex_and_stats" + +# Export the database password for psql command +export PGPASSWORD="$DATABASE_PASSWORD" + +# Check if directory exists +if [ ! -d "$SQL_DIR" ]; then + echo "Directory $SQL_DIR does not exist." + exit 1 +fi + +# Find all SQL files in the directory, sort them numerically, and loop through each one +for sql_file in $(ls $SQL_DIR/*.sql | sort -V); do + echo "Running $sql_file ..." + + # Create a temporary file for the modified SQL + temp_file=$(mktemp) + + # Check if password is empty and exit if it is! + if [ -z "$CUSTOM_SQL_DATABASE_PASSWORD" ]; then + echo "CUSTOM_SQL_DATABASE_PASSWORD is empty. Exiting..." + exit 1 + fi + + # Run the modified SQL file + psql -h "$DATABASE_HOSTNAME" -U "$DATABASE_USERNAME" -d "$DATABASE_NAME" -p "$DATABASE_PORT" -f "$temp_file" + + # Check for errors + if [ $? -ne 0 ]; then + echo "Error occurred while executing $sql_file. Exiting." + rm "$temp_file" # Remove the temp file if an error occurs + exit 1 + fi + + # Remove the temporary file after successful execution + rm "$temp_file" +done + +echo "All scripts executed successfully." + +# Unset the password environment variable +unset PGPASSWORD diff --git a/terraform/environment/terraform.tfvars.json b/terraform/environment/terraform.tfvars.json index 3e2bc643cc..4527188e63 100644 --- a/terraform/environment/terraform.tfvars.json +++ b/terraform/environment/terraform.tfvars.json @@ -70,7 +70,7 @@ "memory_medium": "2048", "memory_high": "4096", "backup_retention_period": 1, - "psql_engine_version": "16.4", + "psql_engine_version": "14.13", "alarms_active": false, "dr_backup": false, "ecs_scale_min": 1, @@ -158,7 +158,7 @@ "memory_medium": "1024", "memory_high": "4096", "backup_retention_period": 1, - "psql_engine_version": "16.4", + "psql_engine_version": "14.13", "alarms_active": true, "dr_backup": true, "ecs_scale_min": 2, @@ -248,7 +248,7 @@ "memory_medium": "1024", "memory_high": "2048", "backup_retention_period": 1, - "psql_engine_version": "16.4", + "psql_engine_version": "14.13", "alarms_active": false, "dr_backup": false, "ecs_scale_min": 1,