--
--



--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: 
--

CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;


--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: 
--

COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';



--
-- Name: update_page_number_based_on_document_id_ignore_section_or_table(integer, text, text); Type: FUNCTION; Schema: public; Owner: gazelle
--

CREATE FUNCTION update_page_number_based_on_document_id_ignore_section_or_table(document_id integer, content text, page text) RETURNS integer
    LANGUAGE plpgsql
    AS $_$
DECLARE
    mviews RECORD;
BEGIN
        FOR mviews IN   select distinct idscheme 
                        from am_oasis_target as t 
                        join am_oasis_test_assertion as ta on t.id=ta.target_id 
                        join am_oasis_normative_source as ns on ns.id=ta.normative_source_id 
                        join am_oasis_normative_source_ref_source_item  as sr on sr.normative_source_id=ns.id 
                        join am_oasis_ref_source_item as r on r.id=sr.ref_source_item_id
                        where r.id=$1 
    LOOP	
        PERFORM "update_page_number_based_scheme_and_content"(mviews.idscheme, content, page);
    END LOOP;
RETURN 1;
END;
$_$;


ALTER FUNCTION public.update_page_number_based_on_document_id_ignore_section_or_table(document_id integer, content text, page text) OWNER TO gazelle;

--
-- Name: update_page_number_based_on_scheme_and_assertion_id(text, text, integer); Type: FUNCTION; Schema: public; Owner: gazelle
--

CREATE FUNCTION update_page_number_based_on_scheme_and_assertion_id(id_scheme text, assertion_id text, page integer) RETURNS integer
    LANGUAGE plpgsql
    AS $_$
BEGIN
update am_oasis_tag set content=$3 where id in(
select am_oasis_tag.id
from
am_oasis_tag,
am_oasis_test_assertion_tag,
am_oasis_test_assertion
where name='Page'
and am_oasis_test_assertion_tag.tag_id = am_oasis_tag.id
and am_oasis_test_assertion_tag.test_assertion_id= am_oasis_test_assertion.id
and am_oasis_test_assertion.assertion_id = $2
and am_oasis_test_assertion.id in(
select am_oasis_test_assertion.id
FROM
am_oasis_test_assertion_tag,
am_oasis_test_assertion,
am_oasis_target
WHERE 
am_oasis_test_assertion_tag.tag_id=am_oasis_tag.id
AND am_oasis_test_assertion.id = am_oasis_test_assertion_tag.test_assertion_id
And am_oasis_target.idscheme=$1
AND am_oasis_target.id = am_oasis_test_assertion.target_id
)
);
return 1 ;
END;
$_$;


ALTER FUNCTION public.update_page_number_based_on_scheme_and_assertion_id(id_scheme text, assertion_id text, page integer) OWNER TO gazelle;

--
-- Name: update_page_number_based_on_scheme_and_section(text, text, integer); Type: FUNCTION; Schema: public; Owner: gazelle
--

CREATE FUNCTION update_page_number_based_on_scheme_and_section(id_scheme text, section_name text, page integer) RETURNS integer
    LANGUAGE plpgsql
    AS $_$
BEGIN
update am_oasis_tag set content=$3 where id in(
select am_oasis_tag.id
from 
am_oasis_tag,
am_oasis_test_assertion_tag,
am_oasis_test_assertion
where name='Page'
and am_oasis_test_assertion_tag.tag_id = am_oasis_tag.id
and am_oasis_test_assertion_tag.test_assertion_id= am_oasis_test_assertion.id
and am_oasis_test_assertion.id in(
select am_oasis_test_assertion.id
FROM am_oasis_tag,
am_oasis_test_assertion_tag,
am_oasis_test_assertion,
am_oasis_target
WHERE am_oasis_tag.name ='Section' 
AND am_oasis_tag.content =$2
AND am_oasis_test_assertion_tag.tag_id=am_oasis_tag.id
AND am_oasis_test_assertion.id = am_oasis_test_assertion_tag.test_assertion_id
And am_oasis_target.idscheme=$1
AND am_oasis_target.id = am_oasis_test_assertion.target_id
)
);
return 1 ;
END;
$_$;


ALTER FUNCTION public.update_page_number_based_on_scheme_and_section(id_scheme text, section_name text, page integer) OWNER TO gazelle;

--
-- Name: update_page_number_based_scheme_and_content(text, text, text); Type: FUNCTION; Schema: public; Owner: gazelle
--

CREATE FUNCTION update_page_number_based_scheme_and_content(schemeid text, contentstring text, pagenumber text) RETURNS integer
    LANGUAGE plpgsql
    AS $_$
BEGIN
update am_oasis_tag set content=$3 where id in(
    select am_oasis_tag.id
    from
    am_oasis_tag,
    am_oasis_test_assertion_tag,
    am_oasis_test_assertion
    where name='Page'
    and am_oasis_test_assertion_tag.tag_id = am_oasis_tag.id
    and am_oasis_test_assertion_tag.test_assertion_id= am_oasis_test_assertion.id
    and am_oasis_test_assertion.id in(
        select am_oasis_test_assertion.id
        FROM am_oasis_tag,
        am_oasis_test_assertion_tag,
        am_oasis_test_assertion,
        am_oasis_target
        WHERE am_oasis_tag.content = $2
        AND am_oasis_test_assertion_tag.tag_id=am_oasis_tag.id
        AND am_oasis_test_assertion.id = am_oasis_test_assertion_tag.test_assertion_id
        And am_oasis_target.idscheme=$1
        AND am_oasis_target.id = am_oasis_test_assertion.target_id
        )
    );
return 1 ;
END;
$_$;


ALTER FUNCTION public.update_page_number_based_scheme_and_content(schemeid text, contentstring text, pagenumber text) OWNER TO gazelle;

--
-- Name: update_page_number_based_scheme_and_table(text, text, integer); Type: FUNCTION; Schema: public; Owner: gazelle
--

CREATE FUNCTION update_page_number_based_scheme_and_table(schemeid text, tablestring text, pagenumber integer) RETURNS boolean
    LANGUAGE plpgsql
    AS $_$BEGIN
update am_oasis_tag set content=$3 where id in(
select am_oasis_tag.id
from 
am_oasis_tag,
am_oasis_test_assertion_tag,
am_oasis_test_assertion
where name='Page'
and am_oasis_test_assertion_tag.tag_id = am_oasis_tag.id
and am_oasis_test_assertion_tag.test_assertion_id= am_oasis_test_assertion.id
and am_oasis_test_assertion.id in(
select am_oasis_test_assertion.id
FROM am_oasis_tag,
am_oasis_test_assertion_tag,
am_oasis_test_assertion,
am_oasis_target
WHERE am_oasis_tag.name ='Table' 
AND regexp_replace(am_oasis_tag.content, '-[0-9]*', '') = $2
AND am_oasis_test_assertion_tag.tag_id=am_oasis_tag.id
AND am_oasis_test_assertion.id = am_oasis_test_assertion_tag.test_assertion_id
And am_oasis_target.idscheme=$1
AND am_oasis_target.id = am_oasis_test_assertion.target_id
)
);
return 1 ;
END;$_$;


ALTER FUNCTION public.update_page_number_based_scheme_and_table(schemeid text, tablestring text, pagenumber integer) OWNER TO gazelle;

--
-- Name: update_section_number_based_on_scheme_and_page_number(text, text, text); Type: FUNCTION; Schema: public; Owner: gazelle
--

CREATE FUNCTION update_section_number_based_on_scheme_and_page_number(id_scheme text, section_name text, page text) RETURNS integer
    LANGUAGE plpgsql
    AS $_$BEGIN
update am_oasis_tag set content=$2, last_changed = 'now' where id in(
select am_oasis_tag.id
from 
am_oasis_tag,
am_oasis_test_assertion_tag,
am_oasis_test_assertion
where name='Section'
and am_oasis_test_assertion_tag.tag_id = am_oasis_tag.id
and am_oasis_test_assertion_tag.test_assertion_id= am_oasis_test_assertion.id
and am_oasis_test_assertion.id in(
select am_oasis_test_assertion.id
FROM am_oasis_tag,
am_oasis_test_assertion_tag,
am_oasis_test_assertion,
am_oasis_target
WHERE am_oasis_tag.name ='Page' 
AND am_oasis_tag.content =$3
AND am_oasis_test_assertion_tag.tag_id=am_oasis_tag.id
AND am_oasis_test_assertion.id = am_oasis_test_assertion_tag.test_assertion_id
And am_oasis_target.idscheme=$1
AND am_oasis_target.id = am_oasis_test_assertion.target_id
)
);
return 1 ;
END;
$_$;


ALTER FUNCTION public.update_section_number_based_on_scheme_and_page_number(id_scheme text, section_name text, page text) OWNER TO gazelle;

--
-- Name: update_section_number_based_scheme_and_assertion_id(text, text, text); Type: FUNCTION; Schema: public; Owner: gazelle
--

CREATE FUNCTION update_section_number_based_scheme_and_assertion_id(schemeid text, assertion text, sectionnumber text) RETURNS integer
    LANGUAGE plpgsql
    AS $_$
BEGIN
update am_oasis_tag
set content=$3 where id in (
	select t.id
	from
	am_oasis_tag t,
	am_oasis_test_assertion_tag tat,
	am_oasis_test_assertion ta, 
	am_oasis_target ot 
	where 	t.name in ('Section', 'Table', 'Figure')
	and 	t.id = tat.tag_id
	and 	tat.test_assertion_id = ta.id
	and 	ot.id = ta.target_id
	and 	ta.id in(
			select ta.id
			FROM am_oasis_tag t,
			am_oasis_test_assertion_tag tat,
			am_oasis_test_assertion ta,
			am_oasis_target ot
			WHERE ta.assertion_id = $2
			AND tat.tag_id = t.id
			AND ta.id = tat.test_assertion_id
			And ot.idscheme=$1
			AND ot.id = ta.target_id
        	)

	);
return 1 ;
END;
$_$;


ALTER FUNCTION public.update_section_number_based_scheme_and_assertion_id(schemeid text, assertion text, sectionnumber text) OWNER TO gazelle;

--
-- Name: update_section_number_based_scheme_and_assertion_id(text, text, text, text); Type: FUNCTION; Schema: public; Owner: gazelle
--

CREATE FUNCTION update_section_number_based_scheme_and_assertion_id(schemeid text, assertion text, sectionnumber text, sectionname text) RETURNS integer
    LANGUAGE plpgsql
    AS $_$
BEGIN
update am_oasis_tag
set content=$3, name=$4 where id in (
	select t.id
	from
	am_oasis_tag t,
	am_oasis_test_assertion_tag tat,
	am_oasis_test_assertion ta,
	am_oasis_target ot
	where 	t.name in ('Section', 'Table', 'Figure')
	and 	t.id = tat.tag_id
	and 	tat.test_assertion_id = ta.id
	and 	ot.id = ta.target_id
	and 	ta.id in(
			select ta.id
			FROM am_oasis_tag t,
			am_oasis_test_assertion_tag tat,
			am_oasis_test_assertion ta,
			am_oasis_target ot
			WHERE ta.assertion_id = $2
			AND tat.tag_id = t.id
			AND ta.id = tat.test_assertion_id
			And ot.idscheme=$1
			AND ot.id = ta.target_id
        	)

	);
return 1 ;
END;
$_$;


ALTER FUNCTION public.update_section_number_based_scheme_and_assertion_id(schemeid text, assertion text, sectionnumber text, sectionname text) OWNER TO gazelle;



--
-- Name: am_assertion_scope; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE am_assertion_scope (
    id integer NOT NULL,
    description text,
    keyword character varying(64) NOT NULL
);


ALTER TABLE am_assertion_scope OWNER TO gazelle;

--
-- Name: am_assertion_scope_id_seq; Type: SEQUENCE; Schema: public; Owner: gazelle
--

CREATE SEQUENCE am_assertion_scope_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE am_assertion_scope_id_seq OWNER TO gazelle;

--
-- Name: am_assertion_scope_links; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE am_assertion_scope_links (
    father_scope_id integer NOT NULL,
    child_scope_id integer NOT NULL
);


ALTER TABLE am_assertion_scope_links OWNER TO gazelle;

--
-- Name: am_assertion_scope_to_test_assertions; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE am_assertion_scope_to_test_assertions (
    scope_id integer NOT NULL,
    assertion_id integer NOT NULL
);


ALTER TABLE am_assertion_scope_to_test_assertions OWNER TO gazelle;

--
-- Name: am_assertions_applies_to; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE am_assertions_applies_to (
    linked_entity character varying(31) NOT NULL,
    id integer NOT NULL,
    linked_entity_id integer NOT NULL,
    linked_entity_keyword character varying(255) NOT NULL,
    linked_entity_name character varying(255) NOT NULL,
    linked_entity_permalink character varying(255) NOT NULL,
    linked_entity_provider character varying(255) NOT NULL,
    assertion_id integer NOT NULL
);


ALTER TABLE am_assertions_applies_to OWNER TO gazelle;

--
-- Name: am_assertions_applies_to_id_seq; Type: SEQUENCE; Schema: public; Owner: gazelle
--

CREATE SEQUENCE am_assertions_applies_to_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE am_assertions_applies_to_id_seq OWNER TO gazelle;

--
-- Name: am_assertions_links; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE am_assertions_links (
    linked_entity character varying(31) NOT NULL,
    id integer NOT NULL,
    linked_entity_keyword character varying(255) NOT NULL,
    assertion_id integer NOT NULL,
    linked_entity_name character varying(255),
    linked_entity_permalink character varying(255),
    linked_entity_provider character varying(255),
    deprecated boolean DEFAULT false
);


ALTER TABLE am_assertions_links OWNER TO gazelle;

--
-- Name: am_assertions_links_id_seq; Type: SEQUENCE; Schema: public; Owner: gazelle
--

CREATE SEQUENCE am_assertions_links_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE am_assertions_links_id_seq OWNER TO gazelle;

--
-- Name: am_assertions_links_mbv; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE am_assertions_links_mbv (
    id integer NOT NULL,
    assertion_id integer NOT NULL,
    mbv_service_id integer NOT NULL
);


ALTER TABLE am_assertions_links_mbv OWNER TO gazelle;

--
-- Name: am_assertions_links_mbv_id_seq; Type: SEQUENCE; Schema: public; Owner: gazelle
--

CREATE SEQUENCE am_assertions_links_mbv_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE am_assertions_links_mbv_id_seq OWNER TO gazelle;

--
-- Name: am_mbv_coverage_status; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE am_mbv_coverage_status (
    id integer NOT NULL,
    assertion_id character varying(255) NOT NULL,
    coverage_status integer,
    id_scheme character varying(255) NOT NULL,
    mbv_service_id integer NOT NULL
);


ALTER TABLE am_mbv_coverage_status OWNER TO gazelle;

--
-- Name: am_mbv_coverage_status_id_seq; Type: SEQUENCE; Schema: public; Owner: gazelle
--

CREATE SEQUENCE am_mbv_coverage_status_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE am_mbv_coverage_status_id_seq OWNER TO gazelle;

--
-- Name: am_mbv_service; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE am_mbv_service (
    id integer NOT NULL,
    name character varying(64) NOT NULL,
    url character varying(255) NOT NULL,
    last_changed timestamp without time zone,
    last_modifier_id character varying(255),
    last_updated timestamp without time zone,
    update_status integer
);


ALTER TABLE am_mbv_service OWNER TO gazelle;

--
-- Name: am_mbv_service_id_seq; Type: SEQUENCE; Schema: public; Owner: gazelle
--

CREATE SEQUENCE am_mbv_service_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE am_mbv_service_id_seq OWNER TO gazelle;

--
-- Name: am_oasis_comment; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE am_oasis_comment (
    id integer NOT NULL,
    last_changed timestamp without time zone,
    last_modifier_id character varying(255),
    content text
);


ALTER TABLE am_oasis_comment OWNER TO gazelle;

--
-- Name: am_oasis_comment_id_seq; Type: SEQUENCE; Schema: public; Owner: gazelle
--

CREATE SEQUENCE am_oasis_comment_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE am_oasis_comment_id_seq OWNER TO gazelle;

--
-- Name: am_oasis_derived_source_item; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE am_oasis_derived_source_item (
    id integer NOT NULL,
    last_changed timestamp without time zone,
    last_modifier_id character varying(255),
    content text,
    date_string character varying(255),
    document_id text,
    name text,
    resource_provenance_id text,
    revision_id text,
    uri text,
    version_id text
);


ALTER TABLE am_oasis_derived_source_item OWNER TO gazelle;

--
-- Name: am_oasis_derived_source_item_id_seq; Type: SEQUENCE; Schema: public; Owner: gazelle
--

CREATE SEQUENCE am_oasis_derived_source_item_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE am_oasis_derived_source_item_id_seq OWNER TO gazelle;

--
-- Name: am_oasis_description; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE am_oasis_description (
    id integer NOT NULL,
    last_changed timestamp without time zone,
    last_modifier_id character varying(255),
    content text
);


ALTER TABLE am_oasis_description OWNER TO gazelle;

--
-- Name: am_oasis_description_id_seq; Type: SEQUENCE; Schema: public; Owner: gazelle
--

CREATE SEQUENCE am_oasis_description_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE am_oasis_description_id_seq OWNER TO gazelle;

--
-- Name: am_oasis_interpretation; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE am_oasis_interpretation (
    id integer NOT NULL,
    last_changed timestamp without time zone,
    last_modifier_id character varying(255),
    content text
);


ALTER TABLE am_oasis_interpretation OWNER TO gazelle;

--
-- Name: am_oasis_interpretation_id_seq; Type: SEQUENCE; Schema: public; Owner: gazelle
--

CREATE SEQUENCE am_oasis_interpretation_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE am_oasis_interpretation_id_seq OWNER TO gazelle;

--
-- Name: am_oasis_normative_source; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE am_oasis_normative_source (
    id integer NOT NULL,
    last_changed timestamp without time zone,
    last_modifier_id character varying(255),
    content text,
    comment_id integer,
    interpretation_id integer
);


ALTER TABLE am_oasis_normative_source OWNER TO gazelle;

--
-- Name: am_oasis_normative_source_derived_source_item; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE am_oasis_normative_source_derived_source_item (
    normative_source_id integer NOT NULL,
    derived_source_item_id integer NOT NULL
);


ALTER TABLE am_oasis_normative_source_derived_source_item OWNER TO gazelle;

--
-- Name: am_oasis_normative_source_id_seq; Type: SEQUENCE; Schema: public; Owner: gazelle
--

CREATE SEQUENCE am_oasis_normative_source_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE am_oasis_normative_source_id_seq OWNER TO gazelle;

--
-- Name: am_oasis_normative_source_ref_source_item; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE am_oasis_normative_source_ref_source_item (
    normative_source_id integer NOT NULL,
    ref_source_item_id integer NOT NULL
);


ALTER TABLE am_oasis_normative_source_ref_source_item OWNER TO gazelle;

--
-- Name: am_oasis_normative_source_text_source_item; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE am_oasis_normative_source_text_source_item (
    normative_source_id integer NOT NULL,
    text_source_item_id integer NOT NULL
);


ALTER TABLE am_oasis_normative_source_text_source_item OWNER TO gazelle;

--
-- Name: am_oasis_predicate; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE am_oasis_predicate (
    id integer NOT NULL,
    last_changed timestamp without time zone,
    last_modifier_id character varying(255),
    content text NOT NULL,
    language integer
);


ALTER TABLE am_oasis_predicate OWNER TO gazelle;

--
-- Name: am_oasis_predicate_id_seq; Type: SEQUENCE; Schema: public; Owner: gazelle
--

CREATE SEQUENCE am_oasis_predicate_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE am_oasis_predicate_id_seq OWNER TO gazelle;

--
-- Name: am_oasis_prerequisite; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE am_oasis_prerequisite (
    id integer NOT NULL,
    last_changed timestamp without time zone,
    last_modifier_id character varying(255),
    content text NOT NULL,
    language integer
);


ALTER TABLE am_oasis_prerequisite OWNER TO gazelle;

--
-- Name: am_oasis_prerequisite_id_seq; Type: SEQUENCE; Schema: public; Owner: gazelle
--

CREATE SEQUENCE am_oasis_prerequisite_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE am_oasis_prerequisite_id_seq OWNER TO gazelle;

--
-- Name: am_oasis_prescription; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE am_oasis_prescription (
    id integer NOT NULL,
    last_changed timestamp without time zone,
    last_modifier_id character varying(255),
    content text,
    level integer NOT NULL
);


ALTER TABLE am_oasis_prescription OWNER TO gazelle;

--
-- Name: am_oasis_prescription_id_seq; Type: SEQUENCE; Schema: public; Owner: gazelle
--

CREATE SEQUENCE am_oasis_prescription_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE am_oasis_prescription_id_seq OWNER TO gazelle;

--
-- Name: am_oasis_ref_source_item; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE am_oasis_ref_source_item (
    id integer NOT NULL,
    last_changed timestamp without time zone,
    last_modifier_id character varying(255),
    document_id text,
    name text,
    resource_provenance_id text,
    revision_id text,
    uri text,
    version_id text
);


ALTER TABLE am_oasis_ref_source_item OWNER TO gazelle;

--
-- Name: am_oasis_ref_source_item_id_seq; Type: SEQUENCE; Schema: public; Owner: gazelle
--

CREATE SEQUENCE am_oasis_ref_source_item_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE am_oasis_ref_source_item_id_seq OWNER TO gazelle;

--
-- Name: am_oasis_tag; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE am_oasis_tag (
    id integer NOT NULL,
    last_changed timestamp without time zone,
    last_modifier_id character varying(255),
    content text,
    name character varying(255) NOT NULL
);


ALTER TABLE am_oasis_tag OWNER TO gazelle;

--
-- Name: am_oasis_tag_id_seq; Type: SEQUENCE; Schema: public; Owner: gazelle
--

CREATE SEQUENCE am_oasis_tag_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE am_oasis_tag_id_seq OWNER TO gazelle;

--
-- Name: am_oasis_target; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE am_oasis_target (
    id integer NOT NULL,
    last_changed timestamp without time zone,
    last_modifier_id character varying(255),
    content text,
    idscheme character varying(255),
    language integer,
    type text
);


ALTER TABLE am_oasis_target OWNER TO gazelle;

--
-- Name: am_oasis_target_id_seq; Type: SEQUENCE; Schema: public; Owner: gazelle
--

CREATE SEQUENCE am_oasis_target_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE am_oasis_target_id_seq OWNER TO gazelle;

--
-- Name: am_oasis_test_assertion; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE am_oasis_test_assertion (
    id integer NOT NULL,
    last_changed timestamp without time zone,
    last_modifier_id character varying(255),
    assertion_id character varying(255) NOT NULL,
    description_id integer,
    normative_source_id integer NOT NULL,
    predicate_id integer NOT NULL,
    prerequisite_id integer,
    prescription_id integer,
    target_id integer NOT NULL,
    comment character varying(1024),
    mbv_coverage_count integer,
    tests_coverage_count integer,
    tf_rules_coverage_count integer,
    status integer,
    applies_to_actor_count integer,
    applies_to_transaction_count integer,
    applies_to_count integer,
    coverage_count integer,
    other_tag_on_assertion character varying(255),
    page_number integer,
    testable boolean DEFAULT true
);


ALTER TABLE am_oasis_test_assertion OWNER TO gazelle;

--
-- Name: COLUMN am_oasis_test_assertion.page_number; Type: COMMENT; Schema: public; Owner: gazelle
--

COMMENT ON COLUMN am_oasis_test_assertion.page_number IS 'Should be deleted ???? ';


--
-- Name: am_oasis_test_assertion_id_seq; Type: SEQUENCE; Schema: public; Owner: gazelle
--

CREATE SEQUENCE am_oasis_test_assertion_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE am_oasis_test_assertion_id_seq OWNER TO gazelle;

--
-- Name: am_oasis_test_assertion_tag; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE am_oasis_test_assertion_tag (
    test_assertion_id integer NOT NULL,
    tag_id integer NOT NULL
);


ALTER TABLE am_oasis_test_assertion_tag OWNER TO gazelle;

--
-- Name: am_oasis_test_assertion_variable; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE am_oasis_test_assertion_variable (
    test_assertion_id integer NOT NULL,
    variable_id integer NOT NULL
);


ALTER TABLE am_oasis_test_assertion_variable OWNER TO gazelle;

--
-- Name: am_oasis_text_source_id_seq; Type: SEQUENCE; Schema: public; Owner: gazelle
--

CREATE SEQUENCE am_oasis_text_source_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE am_oasis_text_source_id_seq OWNER TO gazelle;

--
-- Name: am_oasis_text_source_item; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE am_oasis_text_source_item (
    id integer NOT NULL,
    last_changed timestamp without time zone,
    last_modifier_id character varying(255),
    content text,
    name character varying(255)
);


ALTER TABLE am_oasis_text_source_item OWNER TO gazelle;

--
-- Name: am_oasis_variable; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE am_oasis_variable (
    id integer NOT NULL,
    last_changed timestamp without time zone,
    last_modifier_id character varying(255),
    content text,
    language integer,
    name character varying(255) NOT NULL
);


ALTER TABLE am_oasis_variable OWNER TO gazelle;

--
-- Name: am_oasis_variable_id_seq; Type: SEQUENCE; Schema: public; Owner: gazelle
--

CREATE SEQUENCE am_oasis_variable_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE am_oasis_variable_id_seq OWNER TO gazelle;

--
-- Name: app_configuration; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE app_configuration (
    id integer NOT NULL,
    value character varying(255),
    variable character varying(255)
);


ALTER TABLE app_configuration OWNER TO gazelle;

--
-- Name: app_configuration_id_seq; Type: SEQUENCE; Schema: public; Owner: gazelle
--

CREATE SEQUENCE app_configuration_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE app_configuration_id_seq OWNER TO gazelle;

--
-- Name: cmn_application_preference; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE cmn_application_preference (
    id integer NOT NULL,
    class_name character varying(255) NOT NULL,
    description character varying(255) NOT NULL,
    preference_name character varying(64) NOT NULL,
    preference_value character varying(512) NOT NULL
);


ALTER TABLE cmn_application_preference OWNER TO gazelle;

--
-- Name: cmn_application_preference_id_seq; Type: SEQUENCE; Schema: public; Owner: gazelle
--

CREATE SEQUENCE cmn_application_preference_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE cmn_application_preference_id_seq OWNER TO gazelle;

--
-- Name: cmn_home; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE cmn_home (
    id integer NOT NULL,
    home_title character varying(255),
    iso3_language character varying(255),
    main_content text
);


ALTER TABLE cmn_home OWNER TO gazelle;

--
-- Name: cmn_home_id_seq; Type: SEQUENCE; Schema: public; Owner: gazelle
--

CREATE SEQUENCE cmn_home_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE cmn_home_id_seq OWNER TO gazelle;

--
-- Name: cmn_path_linking_a_document; Type: TABLE; Schema: public; Owner: gazelle
--

CREATE TABLE cmn_path_linking_a_document (
    id integer NOT NULL,
    comment character varying(255),
    path character varying(255) NOT NULL,
    type character varying(255) NOT NULL
);


ALTER TABLE cmn_path_linking_a_document OWNER TO gazelle;

--
-- Name: cmn_path_linking_a_document_id_seq; Type: SEQUENCE; Schema: public; Owner: gazelle
--

CREATE SEQUENCE cmn_path_linking_a_document_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE cmn_path_linking_a_document_id_seq OWNER TO gazelle;

--
-- Name: hpd_ldap_object_classes_id_seq; Type: SEQUENCE; Schema: public; Owner: gazelle
--

CREATE SEQUENCE hpd_ldap_object_classes_id_seq
    START WITH 0
    INCREMENT BY 1
    MINVALUE 0
    NO MAXVALUE
    CACHE 1;


ALTER TABLE hpd_ldap_object_classes_id_seq OWNER TO gazelle;

--
-- Name: am_assertion_scope am_assertion_scope_keyword_key; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_assertion_scope
    ADD CONSTRAINT am_assertion_scope_keyword_key UNIQUE (keyword);


--
-- Name: am_assertion_scope_links am_assertion_scope_links_father_scope_id_child_scope_id_key; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_assertion_scope_links
    ADD CONSTRAINT am_assertion_scope_links_father_scope_id_child_scope_id_key UNIQUE (father_scope_id, child_scope_id);


--
-- Name: am_assertion_scope am_assertion_scope_pkey; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_assertion_scope
    ADD CONSTRAINT am_assertion_scope_pkey PRIMARY KEY (id);


--
-- Name: am_assertion_scope_to_test_assertions am_assertion_scope_to_test_assertions_scope_id_assertion_id_key; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_assertion_scope_to_test_assertions
    ADD CONSTRAINT am_assertion_scope_to_test_assertions_scope_id_assertion_id_key UNIQUE (scope_id, assertion_id);


--
-- Name: am_assertions_applies_to am_assertions_applies_to_pkey; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_assertions_applies_to
    ADD CONSTRAINT am_assertions_applies_to_pkey PRIMARY KEY (id);


--
-- Name: am_assertions_links am_assertions_links_linked_entity_linked_entity_keyword_ass_key; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_assertions_links
    ADD CONSTRAINT am_assertions_links_linked_entity_linked_entity_keyword_ass_key UNIQUE (linked_entity, linked_entity_keyword, assertion_id);


--
-- Name: am_assertions_links_mbv am_assertions_links_mbv_assertion_id_mbv_service_id_key; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_assertions_links_mbv
    ADD CONSTRAINT am_assertions_links_mbv_assertion_id_mbv_service_id_key UNIQUE (assertion_id, mbv_service_id);


--
-- Name: am_assertions_links_mbv am_assertions_links_mbv_pkey; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_assertions_links_mbv
    ADD CONSTRAINT am_assertions_links_mbv_pkey PRIMARY KEY (id);


--
-- Name: am_assertions_links am_assertions_links_pkey; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_assertions_links
    ADD CONSTRAINT am_assertions_links_pkey PRIMARY KEY (id);


--
-- Name: am_mbv_coverage_status am_mbv_coverage_status_pkey; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_mbv_coverage_status
    ADD CONSTRAINT am_mbv_coverage_status_pkey PRIMARY KEY (id);


--
-- Name: am_mbv_service am_mbv_service_name_key; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_mbv_service
    ADD CONSTRAINT am_mbv_service_name_key UNIQUE (name);


--
-- Name: am_mbv_service am_mbv_service_pkey; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_mbv_service
    ADD CONSTRAINT am_mbv_service_pkey PRIMARY KEY (id);


--
-- Name: am_mbv_service am_mbv_service_url_key; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_mbv_service
    ADD CONSTRAINT am_mbv_service_url_key UNIQUE (url);


--
-- Name: am_oasis_comment am_oasis_comment_pkey; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_comment
    ADD CONSTRAINT am_oasis_comment_pkey PRIMARY KEY (id);


--
-- Name: am_oasis_derived_source_item am_oasis_derived_source_item_pkey; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_derived_source_item
    ADD CONSTRAINT am_oasis_derived_source_item_pkey PRIMARY KEY (id);


--
-- Name: am_oasis_description am_oasis_description_pkey; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_description
    ADD CONSTRAINT am_oasis_description_pkey PRIMARY KEY (id);


--
-- Name: am_oasis_interpretation am_oasis_interpretation_pkey; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_interpretation
    ADD CONSTRAINT am_oasis_interpretation_pkey PRIMARY KEY (id);


--
-- Name: am_oasis_normative_source am_oasis_normative_source_pkey; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_normative_source
    ADD CONSTRAINT am_oasis_normative_source_pkey PRIMARY KEY (id);


--
-- Name: am_oasis_predicate am_oasis_predicate_pkey; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_predicate
    ADD CONSTRAINT am_oasis_predicate_pkey PRIMARY KEY (id);


--
-- Name: am_oasis_prerequisite am_oasis_prerequisite_pkey; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_prerequisite
    ADD CONSTRAINT am_oasis_prerequisite_pkey PRIMARY KEY (id);


--
-- Name: am_oasis_prescription am_oasis_prescription_pkey; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_prescription
    ADD CONSTRAINT am_oasis_prescription_pkey PRIMARY KEY (id);


--
-- Name: am_oasis_ref_source_item am_oasis_ref_source_item_pkey; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_ref_source_item
    ADD CONSTRAINT am_oasis_ref_source_item_pkey PRIMARY KEY (id);


--
-- Name: am_oasis_tag am_oasis_tag_pkey; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_tag
    ADD CONSTRAINT am_oasis_tag_pkey PRIMARY KEY (id);


--
-- Name: am_oasis_target am_oasis_target_pkey; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_target
    ADD CONSTRAINT am_oasis_target_pkey PRIMARY KEY (id);


--
-- Name: am_oasis_test_assertion am_oasis_test_assertion_assertion_id_target_id_key; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_test_assertion
    ADD CONSTRAINT am_oasis_test_assertion_assertion_id_target_id_key UNIQUE (assertion_id, target_id);


--
-- Name: am_oasis_test_assertion am_oasis_test_assertion_pkey; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_test_assertion
    ADD CONSTRAINT am_oasis_test_assertion_pkey PRIMARY KEY (id);


--
-- Name: am_oasis_text_source_item am_oasis_text_source_item_pkey; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_text_source_item
    ADD CONSTRAINT am_oasis_text_source_item_pkey PRIMARY KEY (id);


--
-- Name: am_oasis_variable am_oasis_variable_pkey; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_variable
    ADD CONSTRAINT am_oasis_variable_pkey PRIMARY KEY (id);


--
-- Name: app_configuration app_configuration_pkey; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY app_configuration
    ADD CONSTRAINT app_configuration_pkey PRIMARY KEY (id);


--
-- Name: cmn_application_preference cmn_application_preference_pkey; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY cmn_application_preference
    ADD CONSTRAINT cmn_application_preference_pkey PRIMARY KEY (id);


--
-- Name: cmn_application_preference cmn_application_preference_preference_name_key; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY cmn_application_preference
    ADD CONSTRAINT cmn_application_preference_preference_name_key UNIQUE (preference_name);


--
-- Name: cmn_home cmn_home_pkey; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY cmn_home
    ADD CONSTRAINT cmn_home_pkey PRIMARY KEY (id);


--
-- Name: cmn_path_linking_a_document cmn_path_linking_a_document_pkey; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY cmn_path_linking_a_document
    ADD CONSTRAINT cmn_path_linking_a_document_pkey PRIMARY KEY (id);


--
-- Name: am_oasis_target idscheme_unique; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_target
    ADD CONSTRAINT idscheme_unique UNIQUE (idscheme);


--
-- Name: am_assertion_scope_links uk_9ws8yy0jvnmmchcgjgrp8j0vb; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_assertion_scope_links
    ADD CONSTRAINT uk_9ws8yy0jvnmmchcgjgrp8j0vb UNIQUE (father_scope_id, child_scope_id);


--
-- Name: am_assertion_scope_to_test_assertions uk_eqf9ea1wu1ebnpcsvlpp0f0se; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_assertion_scope_to_test_assertions
    ADD CONSTRAINT uk_eqf9ea1wu1ebnpcsvlpp0f0se UNIQUE (scope_id, assertion_id);


--
-- Name: am_assertions_links uk_fc93bfebnins6oirceany09w7; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_assertions_links
    ADD CONSTRAINT uk_fc93bfebnins6oirceany09w7 UNIQUE (linked_entity, linked_entity_keyword, assertion_id);


--
-- Name: am_assertions_links_mbv uk_flxkvupemx0gnjic835qxhr3i; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_assertions_links_mbv
    ADD CONSTRAINT uk_flxkvupemx0gnjic835qxhr3i UNIQUE (assertion_id, mbv_service_id);


--
-- Name: am_oasis_test_assertion uk_h93e94njivitiij0y7r2wtcn4; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_test_assertion
    ADD CONSTRAINT uk_h93e94njivitiij0y7r2wtcn4 UNIQUE (assertion_id, target_id);


--
-- Name: am_assertions_applies_to uk_ivtsdnyexiit6t9oxn8l1wbvq; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_assertions_applies_to
    ADD CONSTRAINT uk_ivtsdnyexiit6t9oxn8l1wbvq UNIQUE (linked_entity, linked_entity_keyword, assertion_id);


--
-- Name: cmn_home uk_mv2quil5gwcd8bxyc76v4vyy1; Type: CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY cmn_home
    ADD CONSTRAINT uk_mv2quil5gwcd8bxyc76v4vyy1 UNIQUE (iso3_language);


--
-- Name: am_assertion_scope_to_test_assertions fk1e40a915bacacc05; Type: FK CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_assertion_scope_to_test_assertions
    ADD CONSTRAINT fk1e40a915bacacc05 FOREIGN KEY (assertion_id) REFERENCES am_oasis_test_assertion(id);


--
-- Name: am_assertion_scope_to_test_assertions fk1e40a915d49756e5; Type: FK CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_assertion_scope_to_test_assertions
    ADD CONSTRAINT fk1e40a915d49756e5 FOREIGN KEY (scope_id) REFERENCES am_assertion_scope(id);


--
-- Name: am_oasis_normative_source fk34774f86bcf5517; Type: FK CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_normative_source
    ADD CONSTRAINT fk34774f86bcf5517 FOREIGN KEY (comment_id) REFERENCES am_oasis_comment(id);


--
-- Name: am_oasis_normative_source fk34774f8ea3f225d; Type: FK CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_normative_source
    ADD CONSTRAINT fk34774f8ea3f225d FOREIGN KEY (interpretation_id) REFERENCES am_oasis_interpretation(id);


--
-- Name: am_oasis_test_assertion_tag fk527ed3977eff6e92; Type: FK CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_test_assertion_tag
    ADD CONSTRAINT fk527ed3977eff6e92 FOREIGN KEY (test_assertion_id) REFERENCES am_oasis_test_assertion(id);


--
-- Name: am_oasis_test_assertion_tag fk527ed397aeadedb7; Type: FK CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_test_assertion_tag
    ADD CONSTRAINT fk527ed397aeadedb7 FOREIGN KEY (tag_id) REFERENCES am_oasis_tag(id);


--
-- Name: am_assertions_links fk63d4675ebacacc05; Type: FK CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_assertions_links
    ADD CONSTRAINT fk63d4675ebacacc05 FOREIGN KEY (assertion_id) REFERENCES am_oasis_test_assertion(id);


--
-- Name: am_oasis_normative_source_ref_source_item fk65d651c4589d978d; Type: FK CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_normative_source_ref_source_item
    ADD CONSTRAINT fk65d651c4589d978d FOREIGN KEY (ref_source_item_id) REFERENCES am_oasis_ref_source_item(id);


--
-- Name: am_oasis_normative_source_ref_source_item fk65d651c4afb2664a; Type: FK CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_normative_source_ref_source_item
    ADD CONSTRAINT fk65d651c4afb2664a FOREIGN KEY (normative_source_id) REFERENCES am_oasis_normative_source(id);


--
-- Name: am_oasis_test_assertion_variable fk84f5b49f7eff6e92; Type: FK CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_test_assertion_variable
    ADD CONSTRAINT fk84f5b49f7eff6e92 FOREIGN KEY (test_assertion_id) REFERENCES am_oasis_test_assertion(id);


--
-- Name: am_oasis_test_assertion_variable fk84f5b49ff5cd941d; Type: FK CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_test_assertion_variable
    ADD CONSTRAINT fk84f5b49ff5cd941d FOREIGN KEY (variable_id) REFERENCES am_oasis_variable(id);


--
-- Name: am_mbv_coverage_status fk957506d81569506c; Type: FK CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_mbv_coverage_status
    ADD CONSTRAINT fk957506d81569506c FOREIGN KEY (mbv_service_id) REFERENCES am_mbv_service(id);


--
-- Name: am_assertion_scope_links fka59d887e7d0492a8; Type: FK CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_assertion_scope_links
    ADD CONSTRAINT fka59d887e7d0492a8 FOREIGN KEY (child_scope_id) REFERENCES am_assertion_scope(id);


--
-- Name: am_assertion_scope_links fka59d887ef6eb4a68; Type: FK CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_assertion_scope_links
    ADD CONSTRAINT fka59d887ef6eb4a68 FOREIGN KEY (father_scope_id) REFERENCES am_assertion_scope(id);


--
-- Name: am_assertions_links_mbv fkaa25d201569506c; Type: FK CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_assertions_links_mbv
    ADD CONSTRAINT fkaa25d201569506c FOREIGN KEY (mbv_service_id) REFERENCES am_mbv_service(id);


--
-- Name: am_assertions_links_mbv fkaa25d20bacacc05; Type: FK CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_assertions_links_mbv
    ADD CONSTRAINT fkaa25d20bacacc05 FOREIGN KEY (assertion_id) REFERENCES am_oasis_test_assertion(id);


--
-- Name: am_assertions_applies_to fkcc4fce89bacacc05; Type: FK CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_assertions_applies_to
    ADD CONSTRAINT fkcc4fce89bacacc05 FOREIGN KEY (assertion_id) REFERENCES am_oasis_test_assertion(id);


--
-- Name: am_oasis_test_assertion fkd199a2bc351d1ddd; Type: FK CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_test_assertion
    ADD CONSTRAINT fkd199a2bc351d1ddd FOREIGN KEY (prescription_id) REFERENCES am_oasis_prescription(id);


--
-- Name: am_oasis_test_assertion fkd199a2bc426b7ad7; Type: FK CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_test_assertion
    ADD CONSTRAINT fkd199a2bc426b7ad7 FOREIGN KEY (predicate_id) REFERENCES am_oasis_predicate(id);


--
-- Name: am_oasis_test_assertion fkd199a2bc6503485d; Type: FK CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_test_assertion
    ADD CONSTRAINT fkd199a2bc6503485d FOREIGN KEY (prerequisite_id) REFERENCES am_oasis_prerequisite(id);


--
-- Name: am_oasis_test_assertion fkd199a2bcafb2664a; Type: FK CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_test_assertion
    ADD CONSTRAINT fkd199a2bcafb2664a FOREIGN KEY (normative_source_id) REFERENCES am_oasis_normative_source(id);


--
-- Name: am_oasis_test_assertion fkd199a2bcdfe86d77; Type: FK CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_test_assertion
    ADD CONSTRAINT fkd199a2bcdfe86d77 FOREIGN KEY (description_id) REFERENCES am_oasis_description(id);


--
-- Name: am_oasis_test_assertion fkd199a2bcf5a45cbd; Type: FK CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_test_assertion
    ADD CONSTRAINT fkd199a2bcf5a45cbd FOREIGN KEY (target_id) REFERENCES am_oasis_target(id);


--
-- Name: am_oasis_normative_source_derived_source_item fkef852bceafb2664a; Type: FK CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_normative_source_derived_source_item
    ADD CONSTRAINT fkef852bceafb2664a FOREIGN KEY (normative_source_id) REFERENCES am_oasis_normative_source(id);


--
-- Name: am_oasis_normative_source_derived_source_item fkef852bcec42e674d; Type: FK CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_normative_source_derived_source_item
    ADD CONSTRAINT fkef852bcec42e674d FOREIGN KEY (derived_source_item_id) REFERENCES am_oasis_derived_source_item(id);


--
-- Name: am_oasis_normative_source_text_source_item fkfd46690c31d47373; Type: FK CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_normative_source_text_source_item
    ADD CONSTRAINT fkfd46690c31d47373 FOREIGN KEY (text_source_item_id) REFERENCES am_oasis_text_source_item(id);


--
-- Name: am_oasis_normative_source_text_source_item fkfd46690cafb2664a; Type: FK CONSTRAINT; Schema: public; Owner: gazelle
--

ALTER TABLE ONLY am_oasis_normative_source_text_source_item
    ADD CONSTRAINT fkfd46690cafb2664a FOREIGN KEY (normative_source_id) REFERENCES am_oasis_normative_source(id);


--
--

