Skip to content

Commit

Permalink
fix(db): add voucher indexes
Browse files Browse the repository at this point in the history
This commit adds indexes to the voucher tables.  Affected columns:
 1. `voucher.reference_uuid`
 2. `voucher_item.document_uuid`
 3. `voucher_item.entity_uuid`

Closes #1455.
  • Loading branch information
Jonathan Niles authored and jniles committed Mar 31, 2017
1 parent d988cdb commit f17b93e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions server/models/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ CREATE TABLE `patient` (
/* @TODO analyse performance implications of indexing frequently searched columns */
INDEX `registration_date` (`registration_date`),
INDEX `dob` (`dob`),
INDEX `sex` (`sex`),
INDEX `sex` (`sex`),

/* @TODO fulltext index may degrade INSERT performance over time */
FULLTEXT `display_name` (`display_name`),
Expand Down Expand Up @@ -1823,6 +1823,7 @@ CREATE TABLE IF NOT EXISTS `voucher` (
KEY `project_id` (`project_id`),
KEY `currency_id` (`currency_id`),
KEY `user_id` (`user_id`),
INDEX (`reference_uuid`),
FOREIGN KEY (`project_id`) REFERENCES `project` (`id`),
FOREIGN KEY (`currency_id`) REFERENCES `currency` (`id`),
FOREIGN KEY (`user_id`) REFERENCES `user` (`id`),
Expand All @@ -1837,11 +1838,13 @@ CREATE TABLE IF NOT EXISTS `voucher_item` (
`debit` DECIMAL(19,4) UNSIGNED NOT NULL DEFAULT 0.0000,
`credit` DECIMAL(19,4) UNSIGNED NOT NULL DEFAULT 0.0000,
`voucher_uuid` BINARY(16) NOT NULL,
`document_uuid` BINARY(16) DEFAULT NULL,
`entity_uuid` BINARY(16) DEFAULT NULL,
`document_uuid` binary(16) default null,
`entity_uuid` binary(16) default null,
PRIMARY KEY (`uuid`),
KEY `account_id` (`account_id`),
KEY `voucher_uuid` (`voucher_uuid`),
INDEX (`document_uuid`),
INDEX (`entity_uuid`),
FOREIGN KEY (`account_id`) REFERENCES `account` (`id`),
FOREIGN KEY (`voucher_uuid`) REFERENCES `voucher` (`uuid`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Expand Down

0 comments on commit f17b93e

Please sign in to comment.