structure.sql revision cad2121a9e9a87317333b202956ce7478efcc257
--
-- PostgreSQL database dump
--
SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -
--
--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -
--
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: axioms; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE axioms (
id integer NOT NULL,
ontology_id integer NOT NULL,
text character varying(255) NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
--
-- Name: axioms_entities; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE axioms_entities (
axiom_id integer NOT NULL,
entity_id integer NOT NULL,
ontology_id integer NOT NULL
);
--
-- Name: axioms_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE axioms_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: axioms_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
--
-- Name: entities; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE entities (
id integer NOT NULL,
ontology_id integer NOT NULL,
kind character varying(255),
text character varying(255) NOT NULL,
name character varying(255) NOT NULL,
uri character varying(255),
range character varying(255),
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
--
-- Name: entities_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE entities_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: entities_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
--
-- Name: links; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE links (
id integer NOT NULL,
source_id integer NOT NULL,
target_id integer NOT NULL,
kind character varying(255),
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
--
-- Name: links_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE links_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: links_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
--
-- Name: logics; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE logics (
id integer NOT NULL,
name character varying(255),
uri character varying(255),
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
--
-- Name: logics_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE logics_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: logics_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
--
-- Name: metadata; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE metadata (
id integer NOT NULL,
metadatable_id integer,
metadatable_type character varying(255),
key character varying(255),
value character varying(255),
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
--
-- Name: metadata_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE metadata_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: metadata_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
--
-- Name: ontologies; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE ontologies (
id integer NOT NULL,
logic_id integer,
uri character varying(255) NOT NULL,
name character varying(255),
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
--
-- Name: ontologies_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE ontologies_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: ontologies_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
--
-- Name: ontology_versions; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE ontology_versions (
id integer NOT NULL,
user_id integer NOT NULL,
ontology_id integer NOT NULL,
source_uri character varying(255),
raw_file_name character varying(255),
raw_file_size integer,
xml_file_name character varying(255),
xml_file_size integer,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
--
-- Name: ontology_versions_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE ontology_versions_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: ontology_versions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
--
-- Name: schema_migrations; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE schema_migrations (
version character varying(255) NOT NULL
);
--
-- Name: users; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE users (
id integer NOT NULL,
email character varying(255),
encrypted_password character varying(255),
reset_password_token character varying(255),
reset_password_sent_at timestamp without time zone,
remember_created_at timestamp without time zone,
sign_in_count integer DEFAULT 0,
current_sign_in_at timestamp without time zone,
last_sign_in_at timestamp without time zone,
current_sign_in_ip character varying(255),
last_sign_in_ip character varying(255),
confirmation_token character varying(255),
confirmed_at timestamp without time zone,
confirmation_sent_at timestamp without time zone,
unconfirmed_email character varying(255),
failed_attempts integer DEFAULT 0,
unlock_token character varying(255),
name character varying(255),
admin boolean DEFAULT false NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
deleted_at timestamp without time zone
);
--
-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE users_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY ontology_versions ALTER COLUMN id SET DEFAULT nextval('ontology_versions_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
--
-- Name: axioms_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY axioms
--
-- Name: entities_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY entities
--
-- Name: links_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY links
--
-- Name: logics_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY logics
--
-- Name: metadata_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY metadata
--
-- Name: ontologies_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY ontologies
--
-- Name: ontology_versions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY ontology_versions
--
-- Name: users_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY users
--
-- Name: index_axioms_entities_on_axiom_id_and_entity_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE INDEX index_axioms_entities_on_axiom_id_and_entity_id ON axioms_entities USING btree (axiom_id, entity_id);
--
-- Name: index_axioms_entities_on_axiom_id_and_ontology_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE UNIQUE INDEX index_axioms_entities_on_axiom_id_and_ontology_id ON axioms_entities USING btree (axiom_id, ontology_id);
--
-- Name: index_axioms_entities_on_entity_id_and_axiom_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE INDEX index_axioms_entities_on_entity_id_and_axiom_id ON axioms_entities USING btree (entity_id, axiom_id);
--
-- Name: index_axioms_entities_on_entity_id_and_ontology_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE UNIQUE INDEX index_axioms_entities_on_entity_id_and_ontology_id ON axioms_entities USING btree (entity_id, ontology_id);
--
-- Name: index_axioms_on_ontology_id_and_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
--
-- Name: index_axioms_on_ontology_id_and_text; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
--
-- Name: index_entities_on_ontology_id_and_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
--
-- Name: index_entities_on_ontology_id_and_text; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE UNIQUE INDEX index_entities_on_ontology_id_and_text ON entities USING btree (ontology_id, text);
--
-- Name: index_links_on_source_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
--
-- Name: index_links_on_target_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
--
-- Name: index_metadata_on_metadatable_id_and_metadatable_type; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE INDEX index_metadata_on_metadatable_id_and_metadatable_type ON metadata USING btree (metadatable_id, metadatable_type);
--
-- Name: index_ontologies_on_logic_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
--
-- Name: index_ontology_versions_on_ontology_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
--
-- Name: index_ontology_versions_on_user_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
--
-- Name: index_users_on_email; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
--
-- Name: index_users_on_reset_password_token; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE UNIQUE INDEX index_users_on_reset_password_token ON users USING btree (reset_password_token);
--
-- Name: index_users_on_unlock_token; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
--
-- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
--
-- Name: axioms_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY axioms
ADD CONSTRAINT axioms_id_fkey FOREIGN KEY (id, ontology_id) REFERENCES axioms_entities(axiom_id, ontology_id) ON DELETE CASCADE;
--
-- Name: axioms_ontology_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY axioms
ADD CONSTRAINT axioms_ontology_id_fk FOREIGN KEY (ontology_id) REFERENCES ontologies(id) ON DELETE CASCADE;
--
-- Name: entities_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY entities
ADD CONSTRAINT entities_id_fkey FOREIGN KEY (id, ontology_id) REFERENCES axioms_entities(entity_id, ontology_id) ON DELETE CASCADE;
--
-- Name: entities_ontology_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY entities
ADD CONSTRAINT entities_ontology_id_fk FOREIGN KEY (ontology_id) REFERENCES ontologies(id) ON DELETE CASCADE;
--
-- Name: links_source_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY links
--
-- Name: links_target_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY links
--
-- Name: ontologies_logic_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY ontologies
--
-- Name: ontology_versions_ontology_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY ontology_versions
ADD CONSTRAINT ontology_versions_ontology_id_fk FOREIGN KEY (ontology_id) REFERENCES ontologies(id) ON DELETE CASCADE;
--
-- Name: ontology_versions_user_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY ontology_versions
--
-- PostgreSQL database dump complete
--