From f1b9938282d80179dc793aadeb123fb7cbed2e45 Mon Sep 17 00:00:00 2001 From: Russ Allbery 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 Tested-by: Russ Allbery --- perl/sql/Wallet-Schema-0.09-PostgreSQL.sql | 43 +++++++++++++++--------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'perl/sql/Wallet-Schema-0.09-PostgreSQL.sql') diff --git a/perl/sql/Wallet-Schema-0.09-PostgreSQL.sql b/perl/sql/Wallet-Schema-0.09-PostgreSQL.sql index a7b8881..38fc6ca 100644 --- a/perl/sql/Wallet-Schema-0.09-PostgreSQL.sql +++ b/perl/sql/Wallet-Schema-0.09-PostgreSQL.sql @@ -1,6 +1,6 @@ -- -- Created by SQL::Translator::Producer::PostgreSQL --- Created on Fri Jul 11 16:33:49 2014 +-- Created on Fri Jul 11 19:17:17 2014 -- -- -- Table: duo. @@ -27,6 +27,7 @@ CREATE TABLE "acl_history" ( "ah_on" timestamp NOT NULL, PRIMARY KEY ("ah_id") ); +CREATE INDEX "acl_history_idx_ah_acl" on "acl_history" ("ah_acl"); -- -- Table: acl_schemes. @@ -89,6 +90,26 @@ CREATE TABLE "keytab_sync" ( PRIMARY KEY ("ks_name", "ks_target") ); +-- +-- Table: object_history. +-- +DROP TABLE "object_history" CASCADE; +CREATE TABLE "object_history" ( + "oh_id" serial NOT NULL, + "oh_type" character varying(16) NOT NULL, + "oh_name" character varying(255) NOT NULL, + "oh_action" character varying(16) NOT NULL, + "oh_field" character varying(16), + "oh_type_field" character varying(255), + "oh_old" character varying(255), + "oh_new" character varying(255), + "oh_by" character varying(255) NOT NULL, + "oh_from" character varying(255) NOT NULL, + "oh_on" timestamp NOT NULL, + PRIMARY KEY ("oh_id") +); +CREATE INDEX "object_history_idx_oh_type_oh_name" on "object_history" ("oh_type", "oh_name"); + -- -- Table: sync_targets. -- @@ -155,26 +176,6 @@ CREATE INDEX "objects_idx_ob_acl_show" on "objects" ("ob_acl_show"); CREATE INDEX "objects_idx_ob_acl_store" on "objects" ("ob_acl_store"); CREATE INDEX "objects_idx_ob_type" on "objects" ("ob_type"); --- --- Table: object_history. --- -DROP TABLE "object_history" CASCADE; -CREATE TABLE "object_history" ( - "oh_id" serial NOT NULL, - "oh_type" character varying(16) NOT NULL, - "oh_name" character varying(255) NOT NULL, - "oh_action" character varying(16) NOT NULL, - "oh_field" character varying(16), - "oh_type_field" character varying(255), - "oh_old" character varying(255), - "oh_new" character varying(255), - "oh_by" character varying(255) NOT NULL, - "oh_from" character varying(255) NOT NULL, - "oh_on" timestamp NOT NULL, - PRIMARY KEY ("oh_id") -); -CREATE INDEX "object_history_idx_oh_type_oh_name" on "object_history" ("oh_type", "oh_name"); - -- -- Foreign Key Definitions -- -- cgit v1.2.3