From f1b9938282d80179dc793aadeb123fb7cbed2e45 Mon Sep 17 00:00:00 2001
From: Russ Allbery <eagle@eyrie.org>
Date: Fri, 11 Jul 2014 19:26:46 -0700
Subject: Clean up foreign keys and indices for history tables

Previous versions had erroneous foreign key constraints between the
object history table and the objects table.  Remove those constraints,
and an incorrect linkage in the schema for the ACL history, and add
indices for the object type, name, and ACL instead.

Change-Id: Ie0ff2448caa82c7a533a1b9ff5c13029bb6ae4ef
Reviewed-on: https://gerrit.stanford.edu/1526
Reviewed-by: Russ Allbery <rra@stanford.edu>
Tested-by: Russ Allbery <rra@stanford.edu>
---
 perl/sql/Wallet-Schema-0.08-0.09-MySQL.sql | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

(limited to 'perl/sql/Wallet-Schema-0.08-0.09-MySQL.sql')

diff --git a/perl/sql/Wallet-Schema-0.08-0.09-MySQL.sql b/perl/sql/Wallet-Schema-0.08-0.09-MySQL.sql
index acc517e..8127613 100644
--- a/perl/sql/Wallet-Schema-0.08-0.09-MySQL.sql
+++ b/perl/sql/Wallet-Schema-0.08-0.09-MySQL.sql
@@ -4,14 +4,19 @@ BEGIN;
 
 SET foreign_key_checks=0;
 
-CREATE TABLE `duo` (
-  `du_name` varchar(255) NOT NULL,
-  `du_key` varchar(255) NOT NULL,
-  PRIMARY KEY (`du_name`)
+CREATE TABLE duo (
+  du_name varchar(255) NOT NULL,
+  du_key varchar(255) NOT NULL,
+  PRIMARY KEY (du_name)
 );
 
 SET foreign_key_checks=1;
 
+ALTER TABLE acl_history ADD INDEX acl_history_idx_ah_acl (ah_acl);
+
+ALTER TABLE object_history DROP FOREIGN KEY object_history_fk_oh_type_oh_name,
+                           ALTER TABLE object_history;
+
 
 COMMIT;
 
-- 
cgit v1.2.3

