Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DDLS-399 upgrade default, integration and pre rds to 16.4 #1733

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
5 changes: 5 additions & 0 deletions terraform/environment/region/modules/aurora/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ resource "aws_rds_cluster" "cluster" {
storage_encrypted = var.storage_encrypted
vpc_security_group_ids = var.vpc_security_group_ids
tags = var.tags
db_cluster_parameter_group_name = "aurora-14-clust"
db_instance_parameter_group_name = "aurora-14-inst"
iam_database_authentication_enabled = var.iam_database_authentication_enabled
lifecycle {
ignore_changes = [replication_source_identifier]
Expand Down Expand Up @@ -82,6 +84,8 @@ resource "aws_rds_cluster" "cluster_serverless" {
vpc_security_group_ids = var.vpc_security_group_ids
tags = var.tags
iam_database_authentication_enabled = var.iam_database_authentication_enabled
db_cluster_parameter_group_name = "aurora-14-clust"
db_instance_parameter_group_name = "aurora-14-inst"

serverlessv2_scaling_configuration {
min_capacity = 0.5
Expand All @@ -107,6 +111,7 @@ resource "aws_rds_cluster_instance" "serverless_instances" {
performance_insights_enabled = true
performance_insights_kms_key_id = var.kms_key_id
publicly_accessible = var.publicly_accessible
db_parameter_group_name = "aurora-14-inst"
tags = var.tags

timeouts {
Expand Down
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": "13.12",
"psql_engine_version": "14.15",
"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": "13.12",
"psql_engine_version": "14.15",
"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": "13.12",
"psql_engine_version": "14.15",
"alarms_active": false,
"dr_backup": false,
"ecs_scale_min": 1,
Expand Down
Loading