summaryrefslogtreecommitdiff
path: root/perl/Wallet/Schema
diff options
context:
space:
mode:
authorRuss Allbery <eagle@eyrie.org>2014-07-11 19:26:46 -0700
committerRuss Allbery <rra@stanford.edu>2014-07-11 22:38:17 -0700
commitf1b9938282d80179dc793aadeb123fb7cbed2e45 (patch)
tree364c834daed3daa1857feb41f8a8357ed29365e5 /perl/Wallet/Schema
parent02a629dcc319e418b2f4185acb5bfb22bc86b3eb (diff)
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>
Diffstat (limited to 'perl/Wallet/Schema')
-rw-r--r--perl/Wallet/Schema/Result/AclHistory.pm13
-rw-r--r--perl/Wallet/Schema/Result/ObjectHistory.pm14
2 files changed, 14 insertions, 13 deletions
diff --git a/perl/Wallet/Schema/Result/AclHistory.pm b/perl/Wallet/Schema/Result/AclHistory.pm
index d3ef901..11593b7 100644
--- a/perl/Wallet/Schema/Result/AclHistory.pm
+++ b/perl/Wallet/Schema/Result/AclHistory.pm
@@ -1,7 +1,7 @@
# Wallet schema for ACL history.
#
# Written by Jon Robertson <jonrober@stanford.edu>
-# Copyright 2012, 2013
+# Copyright 2012, 2013, 2014
# The Board of Trustees of the Leland Stanford Junior University
#
# See LICENSE for licensing terms.
@@ -103,10 +103,11 @@ __PACKAGE__->add_columns(
);
__PACKAGE__->set_primary_key("ah_id");
-__PACKAGE__->might_have(
- 'acls',
- 'Wallet::Schema::Result::Acl',
- { 'foreign.ac_id' => 'self.ah_id' },
- );
+# Add an index on the ACL.
+sub sqlt_deploy_hook {
+ my ($self, $sqlt_table) = @_;
+ my $name = 'acl_history_idx_ah_acl';
+ $sqlt_table->add_index (name => $name, fields => [qw(ah_acl)]);
+}
1;
diff --git a/perl/Wallet/Schema/Result/ObjectHistory.pm b/perl/Wallet/Schema/Result/ObjectHistory.pm
index 9cbb159..5e9c8bd 100644
--- a/perl/Wallet/Schema/Result/ObjectHistory.pm
+++ b/perl/Wallet/Schema/Result/ObjectHistory.pm
@@ -1,7 +1,7 @@
# Wallet schema for object history.
#
# Written by Jon Robertson <jonrober@stanford.edu>
-# Copyright 2012, 2013
+# Copyright 2012, 2013, 2014
# The Board of Trustees of the Leland Stanford Junior University
#
# See LICENSE for licensing terms.
@@ -125,11 +125,11 @@ __PACKAGE__->add_columns(
);
__PACKAGE__->set_primary_key("oh_id");
-__PACKAGE__->might_have(
- 'objects',
- 'Wallet::Schema::Result::Object',
- { 'foreign.ob_type' => 'self.oh_type',
- 'foreign.ob_name' => 'self.oh_name' },
- );
+# Add an index on object type and object name.
+sub sqlt_deploy_hook {
+ my ($self, $sqlt_table) = @_;
+ my $name = 'object_history_idx_oh_type_oh_name';
+ $sqlt_table->add_index (name => $name, fields => [qw(oh_type oh_name)]);
+}
1;