From 15f120108fe69c7bd005370925ae7d5664f4acc8 Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Fri, 6 Dec 2019 10:50:57 -0500 Subject: [PATCH] db changes: added indexes --- README.md | 2 +- db/jambones-sql.sql | 8 ++++++ db/jambones.sqs | 64 +++++++++++++++++++++++++++++++-------------- 3 files changed, 53 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 3cd8377..97d6e5d 100644 --- a/README.md +++ b/README.md @@ -33,4 +33,4 @@ npm test ``` #### Testing a deployed server -There is a swagger endpoint at `http://:3000/swagger` that can be used to exercise the APIs. Bearer authentication is required, so you will need an auth token (refer to [create-admin-token.sql](db/create-admin-token.sql) to see how to generate one). \ No newline at end of file +There is a swagger endpoint at `http://:3000/swagger` that can be used to exercise the APIs. Bearer authentication is required, so you will need an auth token (refer to [create-admin-token.sql](db/create-admin-token.sql) to see how to generate one).s \ No newline at end of file diff --git a/db/jambones-sql.sql b/db/jambones-sql.sql index 318935b..b26405b 100644 --- a/db/jambones-sql.sql +++ b/db/jambones-sql.sql @@ -180,8 +180,11 @@ CREATE TABLE IF NOT EXISTS `phone_numbers` PRIMARY KEY (`phone_number_sid`) ) ENGINE=InnoDB COMMENT='A phone number that has been assigned to an account'; +CREATE UNIQUE INDEX `applications_idx_name` ON `applications` (`account_sid`,`name`); + CREATE INDEX `applications_application_sid_idx` ON `applications` (`application_sid`); CREATE INDEX `applications_name_idx` ON `applications` (`name`); +CREATE INDEX `applications_account_sid_idx` ON `applications` (`account_sid`); ALTER TABLE `applications` ADD FOREIGN KEY account_sid_idxfk (`account_sid`) REFERENCES `accounts` (`account_sid`); CREATE INDEX `call_routes_call_route_sid_idx` ON `call_routes` (`call_route_sid`); @@ -216,18 +219,23 @@ ALTER TABLE `calls` ADD FOREIGN KEY outbound_user_sid_idxfk (`outbound_user_sid` CREATE INDEX `service_providers_service_provider_sid_idx` ON `service_providers` (`service_provider_sid`); CREATE INDEX `service_providers_name_idx` ON `service_providers` (`name`); CREATE INDEX `api_keys_api_key_sid_idx` ON `api_keys` (`api_key_sid`); +CREATE INDEX `api_keys_account_sid_idx` ON `api_keys` (`account_sid`); ALTER TABLE `api_keys` ADD FOREIGN KEY account_sid_idxfk_2 (`account_sid`) REFERENCES `accounts` (`account_sid`); +CREATE INDEX `api_keys_service_provider_sid_idx` ON `api_keys` (`service_provider_sid`); ALTER TABLE `api_keys` ADD FOREIGN KEY service_provider_sid_idxfk (`service_provider_sid`) REFERENCES `service_providers` (`service_provider_sid`); ALTER TABLE `subscriptions` ADD FOREIGN KEY registration_sid_idxfk (`registration_sid`) REFERENCES `registrations` (`registration_sid`); CREATE INDEX `accounts_account_sid_idx` ON `accounts` (`account_sid`); CREATE INDEX `accounts_name_idx` ON `accounts` (`name`); +CREATE INDEX `accounts_service_provider_sid_idx` ON `accounts` (`service_provider_sid`); ALTER TABLE `accounts` ADD FOREIGN KEY service_provider_sid_idxfk_1 (`service_provider_sid`) REFERENCES `service_providers` (`service_provider_sid`); CREATE INDEX `voip_carriers_voip_carrier_sid_idx` ON `voip_carriers` (`voip_carrier_sid`); +CREATE INDEX `voip_carriers_name_idx` ON `voip_carriers` (`name`); CREATE INDEX `phone_numbers_phone_number_sid_idx` ON `phone_numbers` (`phone_number_sid`); +CREATE INDEX `phone_numbers_voip_carrier_sid_idx` ON `phone_numbers` (`voip_carrier_sid`); ALTER TABLE `phone_numbers` ADD FOREIGN KEY voip_carrier_sid_idxfk (`voip_carrier_sid`) REFERENCES `voip_carriers` (`voip_carrier_sid`); ALTER TABLE `phone_numbers` ADD FOREIGN KEY account_sid_idxfk_3 (`account_sid`) REFERENCES `accounts` (`account_sid`); diff --git a/db/jambones.sqs b/db/jambones.sqs index ac5aa84..ec7ec06 100644 --- a/db/jambones.sqs +++ b/db/jambones.sqs @@ -48,7 +48,7 @@ - + @@ -93,7 +93,7 @@ - + @@ -127,6 +127,7 @@ + @@ -136,7 +137,7 @@ - + @@ -182,6 +183,7 @@ 2 + @@ -197,9 +199,10 @@ 2 + - + @@ -263,7 +266,7 @@ - + @@ -328,7 +331,7 @@ - + @@ -382,6 +385,7 @@ + @@ -391,7 +395,7 @@ - + @@ -448,7 +452,7 @@ - + @@ -682,7 +686,7 @@ - + @@ -730,6 +734,7 @@ 1 + @@ -763,7 +768,7 @@ - + @@ -821,7 +826,7 @@ - + @@ -866,7 +871,7 @@ - + @@ -881,8 +886,8 @@ 351.00 - 278.00 - 120.00 + 345.00 + 140.00 0 @@ -913,6 +918,7 @@ 1 + @@ -929,7 +935,25 @@ - + + + + + + + + + + + + + + + + + + + @@ -991,17 +1015,17 @@ - + - - - + + + - +