structure.sql revision 3ff4a55d2d96372130084b5c9816c0608eb21210
--
-- 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,
name character varying(255) NOT NULL,
range character varying(255),
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),
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),
entities_count integer,
axioms_count integer,
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 character varying(255),
xml_file character varying(255),
last_error character varying(255),
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: permissions; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE permissions (
id integer NOT NULL,
subject_id integer NOT NULL,
subject_type character varying(255) NOT NULL,
item_id integer NOT NULL,
item_type character varying(255) NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
--
-- Name: permissions_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE permissions_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: permissions_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: team_users; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE team_users (
id integer NOT NULL,
team_id integer NOT NULL,
user_id integer NOT NULL,
admin boolean DEFAULT false NOT NULL
);
--
-- Name: team_users_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE team_users_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: team_users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
--
-- Name: teams; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE teams (
id integer NOT NULL,
name character varying(255) NOT NULL
);
--
-- Name: teams_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE teams_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: teams_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
--
-- 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: id; Type: DEFAULT; Schema: public; Owner: -
--
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
--
-- 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: permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY permissions
--
-- Name: team_users_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY team_users
--
-- Name: teams_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY teams
--
-- 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 UNIQUE INDEX index_axioms_entities_on_axiom_id_and_entity_id ON axioms_entities USING btree (axiom_id, entity_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_on_ontology_id_and_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
--
-- Name: index_axioms_on_ontology_id_and_name; 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_permissions_on_item_and_subject; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE UNIQUE INDEX index_permissions_on_item_and_subject ON permissions USING btree (item_id, item_type, subject_id, subject_type);
--
-- Name: index_permissions_on_subject_id_and_subject_type; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE INDEX index_permissions_on_subject_id_and_subject_type ON permissions USING btree (subject_id, subject_type);
--
-- Name: index_team_users_on_team_id_and_user_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE UNIQUE INDEX index_team_users_on_team_id_and_user_id ON team_users USING btree (team_id, user_id);
--
-- Name: index_team_users_on_user_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
--
-- Name: index_teams_on_name; 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_entities_axiom_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY axioms_entities
ADD CONSTRAINT axioms_entities_axiom_id_fkey FOREIGN KEY (axiom_id, ontology_id) REFERENCES axioms(id, ontology_id) ON DELETE CASCADE;
--
-- Name: axioms_entities_entity_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY axioms_entities
ADD CONSTRAINT axioms_entities_entity_id_fkey FOREIGN KEY (entity_id, ontology_id) REFERENCES entities(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_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
--
-- Name: team_users_team_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY team_users
--
-- Name: team_users_user_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY team_users
--
-- PostgreSQL database dump complete
--