structure.sql revision 0be38598001e15ea877bf3d4807e941159753df2
72e60fd4eabcfbcdbfe01e8c38b94052bc6c2067Jakub Hrozek-- PostgreSQL database dump
72e60fd4eabcfbcdbfe01e8c38b94052bc6c2067Jakub Hrozek-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -
72e60fd4eabcfbcdbfe01e8c38b94052bc6c2067Jakub HrozekCREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
341a00311680a440d7f979f06c34c70d86c9367aBohuslav Kabrda-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -
341a00311680a440d7f979f06c34c70d86c9367aBohuslav KabrdaCOMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
72e60fd4eabcfbcdbfe01e8c38b94052bc6c2067Jakub Hrozek-- Name: axioms; Type: TABLE; Schema: public; Owner: -; Tablespace:
72e60fd4eabcfbcdbfe01e8c38b94052bc6c2067Jakub HrozekCREATE TABLE axioms (
72e60fd4eabcfbcdbfe01e8c38b94052bc6c2067Jakub Hrozek id integer NOT NULL,
c6278b2fa4a7ea389ed4086b2def16e0e6cbb184Lukas Slebodnik ontology_id integer NOT NULL,
c6278b2fa4a7ea389ed4086b2def16e0e6cbb184Lukas Slebodnik created_at timestamp without time zone NOT NULL,
72e60fd4eabcfbcdbfe01e8c38b94052bc6c2067Jakub Hrozek updated_at timestamp without time zone NOT NULL
72e60fd4eabcfbcdbfe01e8c38b94052bc6c2067Jakub Hrozek-- Name: axioms_entities; Type: TABLE; Schema: public; Owner: -; Tablespace:
72e60fd4eabcfbcdbfe01e8c38b94052bc6c2067Jakub Hrozek axiom_id integer NOT NULL,
72e60fd4eabcfbcdbfe01e8c38b94052bc6c2067Jakub Hrozek entity_id integer NOT NULL,
72e60fd4eabcfbcdbfe01e8c38b94052bc6c2067Jakub Hrozek ontology_id integer NOT NULL
NO MINVALUE
NO MAXVALUE
CREATE TABLE entities (
id integer NOT NULL,
ontology_id integer NOT NULL,
NO MINVALUE
NO MAXVALUE
CREATE TABLE links (
id integer NOT NULL,
source_id integer NOT NULL,
target_id integer NOT NULL,
NO MINVALUE
NO MAXVALUE
CREATE TABLE logics (
id integer NOT NULL,
NO MINVALUE
NO MAXVALUE
CREATE TABLE ontologies (
id integer NOT NULL,
logic_id integer,
NO MINVALUE
NO MAXVALUE
CREATE TABLE ontology_versions (
id integer NOT NULL,
user_id integer NOT NULL,
ontology_id integer NOT NULL,
raw_file_size integer,
xml_file_size integer,
NO MINVALUE
NO MAXVALUE
CREATE TABLE schema_migrations (
CREATE TABLE users (
id integer NOT NULL,
admin boolean DEFAULT false NOT NULL,
NO MINVALUE
NO MAXVALUE
ALTER TABLE ONLY ontology_versions ALTER COLUMN id SET DEFAULT nextval('ontology_versions_id_seq'::regclass);
ALTER TABLE ONLY axioms
ALTER TABLE ONLY entities
ALTER TABLE ONLY links
ALTER TABLE ONLY logics
ALTER TABLE ONLY ontologies
ALTER TABLE ONLY ontology_versions
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);
CREATE UNIQUE INDEX index_entities_on_ontology_id_and_text ON entities USING btree (ontology_id, text);
CREATE UNIQUE INDEX index_users_on_reset_password_token ON users USING btree (reset_password_token);
ALTER TABLE ONLY axioms
ADD CONSTRAINT axioms_id_fkey FOREIGN KEY (id, ontology_id) REFERENCES axioms_entities(axiom_id, ontology_id) ON DELETE CASCADE;
ALTER TABLE ONLY axioms
ADD CONSTRAINT axioms_ontology_id_fk FOREIGN KEY (ontology_id) REFERENCES ontologies(id) ON DELETE CASCADE;
ALTER TABLE ONLY entities
ADD CONSTRAINT entities_id_fkey FOREIGN KEY (id, ontology_id) REFERENCES axioms_entities(entity_id, ontology_id) ON DELETE CASCADE;
ALTER TABLE ONLY entities
ADD CONSTRAINT entities_ontology_id_fk FOREIGN KEY (ontology_id) REFERENCES ontologies(id) ON DELETE CASCADE;
ALTER TABLE ONLY links
ALTER TABLE ONLY links
ALTER TABLE ONLY ontologies
ALTER TABLE ONLY ontology_versions
ADD CONSTRAINT ontology_versions_ontology_id_fk FOREIGN KEY (ontology_id) REFERENCES ontologies(id) ON DELETE CASCADE;
ALTER TABLE ONLY ontology_versions