diff --git a/database/registry.mariadb.sql b/database/registry.mariadb.sql index eda10eb..381b91a 100644 --- a/database/registry.mariadb.sql +++ b/database/registry.mariadb.sql @@ -934,6 +934,10 @@ INSERT INTO `registry`.`settings` (`name`, `value`) VALUES ('rdap_server', 'https://rdap.example.com'), ('currency', 'USD'); +CREATE INDEX idx_domain_crdate ON domain (crdate DESC); +CREATE INDEX idx_domain_exdate ON domain (exdate); +CREATE INDEX idx_support_tickets_date_created ON support_tickets (date_created); + CREATE DATABASE IF NOT EXISTS `registryTransaction`; CREATE TABLE IF NOT EXISTS `registryTransaction`.`transaction_identifier` ( diff --git a/database/registry.postgres.sql b/database/registry.postgres.sql index 80fe886..1dfa90e 100644 --- a/database/registry.postgres.sql +++ b/database/registry.postgres.sql @@ -912,4 +912,8 @@ ALTER TABLE premium_domain_pricing ADD FOREIGN KEY ("category_id") REFERENCES pr ALTER TABLE support_tickets ADD FOREIGN KEY ("user_id") REFERENCES users(id); ALTER TABLE users_audit ADD FOREIGN KEY ("user_id") REFERENCES users(id); ALTER TABLE support_tickets ADD FOREIGN KEY ("category_id") REFERENCES ticket_categories(id); -ALTER TABLE ticket_responses ADD FOREIGN KEY ("ticket_id") REFERENCES support_tickets(id); \ No newline at end of file +ALTER TABLE ticket_responses ADD FOREIGN KEY ("ticket_id") REFERENCES support_tickets(id); + +CREATE INDEX idx_domain_crdate ON domain (crdate DESC); +CREATE INDEX idx_domain_exdate ON domain (exdate); +CREATE INDEX idx_support_tickets_date_created ON support_tickets (date_created); \ No newline at end of file diff --git a/database/registry.sqlite.sql b/database/registry.sqlite.sql index a5670be..331745e 100644 --- a/database/registry.sqlite.sql +++ b/database/registry.sqlite.sql @@ -375,6 +375,9 @@ CREATE TABLE IF NOT EXISTS domain ( FOREIGN KEY (acid) REFERENCES registrar(id), FOREIGN KEY (tldid) REFERENCES domain_tld(id) ); +CREATE INDEX idx_domain_crdate ON domain (crdate); +CREATE INDEX idx_domain_exdate ON domain (exdate); +CREATE INDEX idx_support_tickets_date_created ON support_tickets (date_created); -- application CREATE TABLE IF NOT EXISTS application ( diff --git a/docs/update1020.sh b/docs/update1020.sh index bbef460..d0a2a8b 100644 --- a/docs/update1020.sh +++ b/docs/update1020.sh @@ -116,24 +116,24 @@ composer_update "/opt/registry/whois/port43" composer_update "/opt/registry/rdap" composer_update "/opt/registry/epp" -# Function to ensure a setting is present, uncommented, and correctly set -set_php_ini_value() { - local ini_file=$1 - local key=$2 - local value=$3 +CONFIG_FILE="/opt/registry/rdap/config.php" - # Escape slashes for sed compatibility - local escaped_value - escaped_value=$(printf '%s\n' "$value" | sed 's/[\/&]/\\&/g') +# Extract database credentials from the config file +DB_NAME=$(grep "'db_database'" "$CONFIG_FILE" | awk -F "=> " '{print $2}' | tr -d "',") +DB_USER=$(grep "'db_username'" "$CONFIG_FILE" | awk -F "=> " '{print $2}' | tr -d "',") +DB_PASS=$(grep "'db_password'" "$CONFIG_FILE" | awk -F "=> " '{print $2}' | tr -d "',") - if grep -Eq "^\s*[;#]?\s*${key}\s*=" "$ini_file"; then - # Update the existing line, uncomment it and set correct value - sed -i -E "s|^\s*[;#]?\s*(${key})\s*=.*|\1 = ${escaped_value}|" "$ini_file" - else - # Add new line if key doesn't exist - echo "${key} = ${value}" >> "$ini_file" - fi -} +# Add indexes for performance improvements +echo "Creating index idx_domain_crdate..." +mysql -u$DB_USER -p$DB_PASS $DB_NAME -e "CREATE INDEX idx_domain_crdate ON domain (crdate DESC);" + +echo "Creating index idx_domain_exdate..." +mysql -u$DB_USER -p$DB_PASS $DB_NAME -e "CREATE INDEX idx_domain_exdate ON domain (exdate);" + +echo "Creating index idx_support_tickets_date_created..." +mysql -u$DB_USER -p$DB_PASS $DB_NAME -e "CREATE INDEX idx_support_tickets_date_created ON support_tickets (date_created);" + +echo "Database structure updated successfully." # Check the Linux distribution and version if [[ -e /etc/os-release ]]; then @@ -196,7 +196,7 @@ apt update # Install MariaDB and PHP MySQL module apt install -y mariadb-client mariadb-server ${PHP_VERSION}-mysql - +systemctl restart mariadb echo "MariaDB updated..." # Restart PHP-FPM service