 --
 CREATE TABLE ip_net_pool (
 	id serial PRIMARY KEY,
-	name text UNIQUE,
-	schema integer REFERENCES ip_net_schema (id) ON UPDATE CASCADE ON DELETE CASCADE DEFAULT 1,
+	name text NOT NULL,
+	schema integer NOT NULL REFERENCES ip_net_schema (id) ON UPDATE CASCADE ON DELETE CASCADE DEFAULT 1,
 	description text,
 	default_type ip_net_plan_type,
 	ipv4_default_prefix_length integer,

--
CREATE TABLE ip_net_schema (
	id serial PRIMARY KEY,
	name text UNIQUE,
	description text,
	vrf text UNIQUE
);

COMMENT ON TABLE ip_net_schema IS 'IP Address schemas, something like namespaces for our address plan';


--

COMMENT ON COLUMN ip_net_plan.monitor IS 'Whether the prefix should be monitored or not.';

CREATE UNIQUE INDEX ip_net_plan__schema_prefix__index ON ip_net_plan (schema, prefix);

COMMENT ON ip_net_plan__schema_prefix__index IS 'Schema / Prefix';
CREATE INDEX ip_net_plan__schema__index ON ip_net_plan (schema);
CREATE INDEX ip_net_plan__node__index ON ip_net_plan (node);
CREATE INDEX ip_net_plan__family__index ON ip_net_plan (family(prefix));
