From 8a9715f183096e35e964a195b61f84bb263a9f85 Mon Sep 17 00:00:00 2001
From: Adam Ierymenko <adam.ierymenko@gmail.com>
Date: Sat, 13 Jun 2015 10:05:34 +0200
Subject: Rename ruleId to ruleNo and optimize some indexes in Sqlite3 schema.

---
 controller/schema.sql | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

(limited to 'controller/schema.sql')

diff --git a/controller/schema.sql b/controller/schema.sql
index a3a7bb7a..25adce40 100644
--- a/controller/schema.sql
+++ b/controller/schema.sql
@@ -32,12 +32,10 @@ CREATE TABLE IpAssignment (
   ipVersion integer NOT NULL DEFAULT(4)
 );
 
-CREATE INDEX IpAssignment_networkId_ip ON IpAssignment (networkId, ip);
+CREATE UNIQUE INDEX IpAssignment_networkId_ip ON IpAssignment (networkId, ip);
 
 CREATE INDEX IpAssignment_networkId_nodeId ON IpAssignment (networkId, nodeId);
 
-CREATE INDEX IpAssignment_networkId ON IpAssignment (networkId);
-
 CREATE TABLE IpAssignmentPool (
   networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,
   ipNetwork blob(16) NOT NULL,
@@ -55,8 +53,6 @@ CREATE TABLE Member (
   PRIMARY KEY (networkId, nodeId)
 );
 
-CREATE INDEX Member_networkId ON Member (networkId);
-
 CREATE INDEX Member_networkId_activeBridge ON Member(networkId, activeBridge);
 
 CREATE TABLE MulticastRate (
@@ -81,7 +77,7 @@ CREATE INDEX Relay_networkId ON Relay (networkId);
 
 CREATE TABLE Rule (
   networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,
-  ruleId integer NOT NULL,
+  ruleNo integer NOT NULL,
   nodeId char(10) NOT NULL REFERENCES Node(id) ON DELETE CASCADE,
   vlanId integer,
   vlanPcp integer,
@@ -99,4 +95,4 @@ CREATE TABLE Rule (
   "action" varchar(4096) NOT NULL DEFAULT('accept')
 );
 
-CREATE INDEX Rule_networkId ON Rule (networkId);
+CREATE UNIQUE INDEX Rule_networkId_ruleNo ON Rule (networkId, ruleNo);
-- 
cgit v1.2.3

