Skip to content

Commit

Permalink
try with v14 instead
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesrwarren committed Nov 25, 2024
1 parent a00b601 commit ac1ff7a
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 3 deletions.
1 change: 1 addition & 0 deletions api/app/scripts/reindex_and_stats/reindex.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REINDEX DATABASE api;
1 change: 1 addition & 0 deletions api/app/scripts/reindex_and_stats/statistics.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ANALYZE;
1 change: 1 addition & 0 deletions api/app/scripts/reset_db_fixtures.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
45 changes: 45 additions & 0 deletions api/app/scripts/setup_reindex.sh
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions terraform/environment/terraform.tfvars.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit ac1ff7a

Please sign in to comment.