-- Table: alf_node

-- DROP TABLE alf_node;

CREATE TABLE alf_node
(
  id bigint NOT NULL,
  version bigint NOT NULL,
  store_id bigint NOT NULL,
  uuid character varying(36) NOT NULL,
  transaction_id bigint NOT NULL,
  node_deleted boolean NOT NULL,
  type_qname_id bigint NOT NULL,
  locale_id bigint NOT NULL,
  acl_id bigint,
  audit_creator character varying(255),
  audit_created character varying(30),
  audit_modifier character varying(255),
  audit_modified character varying(30),
  audit_accessed character varying(30),
  CONSTRAINT alf_node_pkey PRIMARY KEY (id),
  CONSTRAINT fk_alf_node_acl FOREIGN KEY (acl_id)
      REFERENCES alf_access_control_list (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT fk_alf_node_loc FOREIGN KEY (locale_id)
      REFERENCES alf_locale (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT fk_alf_node_store FOREIGN KEY (store_id)
      REFERENCES alf_store (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT fk_alf_node_tqn FOREIGN KEY (type_qname_id)
      REFERENCES alf_qname (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT fk_alf_node_txn FOREIGN KEY (transaction_id)
      REFERENCES alf_transaction (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
  FILLFACTOR=90, 
  OIDS=FALSE
);
ALTER TABLE alf_node
  OWNER TO alfresco;

-- Index: fk_alf_node_acl

-- DROP INDEX fk_alf_node_acl;

CREATE INDEX fk_alf_node_acl
  ON alf_node
  USING btree
  (acl_id);

-- Index: fk_alf_node_loc

-- DROP INDEX fk_alf_node_loc;

CREATE INDEX fk_alf_node_loc
  ON alf_node
  USING btree
  (locale_id);

-- Index: fk_alf_node_store

-- DROP INDEX fk_alf_node_store;

CREATE INDEX fk_alf_node_store
  ON alf_node
  USING btree
  (store_id);

-- Index: fk_alf_node_tqn

-- DROP INDEX fk_alf_node_tqn;

CREATE INDEX fk_alf_node_tqn
  ON alf_node
  USING btree
  (type_qname_id);

-- Index: fk_alf_node_txn

-- DROP INDEX fk_alf_node_txn;

CREATE INDEX fk_alf_node_txn
  ON alf_node
  USING btree
  (transaction_id);

-- Index: idx_alf_node_del

-- DROP INDEX idx_alf_node_del;

CREATE INDEX idx_alf_node_del
  ON alf_node
  USING btree
  (node_deleted);

-- Index: idx_alf_node_txn_del

-- DROP INDEX idx_alf_node_txn_del;

CREATE INDEX idx_alf_node_txn_del
  ON alf_node
  USING btree
  (transaction_id, node_deleted);

-- Index: store_id

-- DROP INDEX store_id;

CREATE UNIQUE INDEX store_id
  ON alf_node
  USING btree
  (store_id, uuid);
