Skip to content

Commit

Permalink
Insert and upgrade SQL for text annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderWatzinger committed Sep 11, 2024
1 parent d0c1a3a commit cb921ea
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 2 deletions.
83 changes: 81 additions & 2 deletions install/1_structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
-- PostgreSQL database dump
--

-- Dumped from database version 15.6 (Debian 15.6-0+deb12u1)
-- Dumped by pg_dump version 15.6 (Debian 15.6-0+deb12u1)
-- Dumped from database version 15.8 (Debian 15.8-0+deb12u1)
-- Dumped by pg_dump version 15.8 (Debian 15.8-0+deb12u1)

SET statement_timeout = 0;
SET lock_timeout = 0;
Expand Down Expand Up @@ -32,6 +32,9 @@ ALTER TABLE IF EXISTS ONLY web.hierarchy DROP CONSTRAINT IF EXISTS hierarchy_id_
ALTER TABLE IF EXISTS ONLY web.hierarchy_openatlas_class DROP CONSTRAINT IF EXISTS hierarchy_form_hierarchy_id_fkey;
ALTER TABLE IF EXISTS ONLY web.entity_profile_image DROP CONSTRAINT IF EXISTS entity_profile_image_image_id_fkey;
ALTER TABLE IF EXISTS ONLY web.entity_profile_image DROP CONSTRAINT IF EXISTS entity_profile_image_entity_id_fkey;
ALTER TABLE IF EXISTS ONLY web.annotation_text DROP CONSTRAINT IF EXISTS annotation_text_user_id_fkey;
ALTER TABLE IF EXISTS ONLY web.annotation_text DROP CONSTRAINT IF EXISTS annotation_text_source_id_fkey;
ALTER TABLE IF EXISTS ONLY web.annotation_text DROP CONSTRAINT IF EXISTS annotation_text_entity_id_fkey;
ALTER TABLE IF EXISTS ONLY web.annotation_image DROP CONSTRAINT IF EXISTS annotation_image_user_id_fkey;
ALTER TABLE IF EXISTS ONLY web.annotation_image DROP CONSTRAINT IF EXISTS annotation_image_image_id_fkey;
ALTER TABLE IF EXISTS ONLY web.annotation_image DROP CONSTRAINT IF EXISTS annotation_image_entity_id_fkey;
Expand Down Expand Up @@ -67,6 +70,7 @@ DROP TRIGGER IF EXISTS update_modified ON web.i18n;
DROP TRIGGER IF EXISTS update_modified ON web.hierarchy_openatlas_class;
DROP TRIGGER IF EXISTS update_modified ON web.hierarchy;
DROP TRIGGER IF EXISTS update_modified ON web."group";
DROP TRIGGER IF EXISTS update_modified ON web.annotation_text;
DROP TRIGGER IF EXISTS update_modified ON model.link;
DROP TRIGGER IF EXISTS update_modified ON model.gis;
DROP TRIGGER IF EXISTS update_modified ON model.file_info;
Expand Down Expand Up @@ -104,6 +108,7 @@ ALTER TABLE IF EXISTS ONLY web."group" DROP CONSTRAINT IF EXISTS group_name_key;
ALTER TABLE IF EXISTS ONLY web.entity_profile_image DROP CONSTRAINT IF EXISTS entity_profile_image_pkey;
ALTER TABLE IF EXISTS ONLY web.entity_profile_image DROP CONSTRAINT IF EXISTS entity_profile_image_entity_id_key;
ALTER TABLE IF EXISTS ONLY web.type_none_selectable DROP CONSTRAINT IF EXISTS entity_id_key;
ALTER TABLE IF EXISTS ONLY web.annotation_text DROP CONSTRAINT IF EXISTS annotation_text_pkey;
ALTER TABLE IF EXISTS ONLY web.annotation_image DROP CONSTRAINT IF EXISTS annotation_image_pkey;
ALTER TABLE IF EXISTS ONLY model.property DROP CONSTRAINT IF EXISTS property_pkey;
ALTER TABLE IF EXISTS ONLY model.property_inheritance DROP CONSTRAINT IF EXISTS property_inheritance_pkey;
Expand Down Expand Up @@ -186,6 +191,8 @@ DROP SEQUENCE IF EXISTS web.group_id_seq;
DROP TABLE IF EXISTS web."group";
DROP SEQUENCE IF EXISTS web.entity_profile_image_id_seq;
DROP TABLE IF EXISTS web.entity_profile_image;
DROP TABLE IF EXISTS web.annotation_text;
DROP SEQUENCE IF EXISTS web.annotation_text_id_seq;
DROP SEQUENCE IF EXISTS web.annotation_image_id_seq;
DROP TABLE IF EXISTS web.annotation_image;
DROP SEQUENCE IF EXISTS model.property_inheritance_id_seq;
Expand Down Expand Up @@ -892,6 +899,39 @@ ALTER TABLE web.annotation_image_id_seq OWNER TO openatlas;
ALTER SEQUENCE web.annotation_image_id_seq OWNED BY web.annotation_image.id;


--
-- Name: annotation_text_id_seq; Type: SEQUENCE; Schema: web; Owner: openatlas
--

CREATE SEQUENCE web.annotation_text_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
MAXVALUE 2147483647
CACHE 1;


ALTER TABLE web.annotation_text_id_seq OWNER TO openatlas;

--
-- Name: annotation_text; Type: TABLE; Schema: web; Owner: openatlas
--

CREATE TABLE web.annotation_text (
id integer DEFAULT nextval('web.annotation_text_id_seq'::regclass) NOT NULL,
source_id integer NOT NULL,
entity_id integer NOT NULL,
link_start integer NOT NULL,
link_end integer NOT NULL,
user_id integer,
text integer,
created timestamp without time zone DEFAULT now() NOT NULL,
modified timestamp without time zone
);


ALTER TABLE web.annotation_text OWNER TO openatlas;

--
-- Name: entity_profile_image; Type: TABLE; Schema: web; Owner: openatlas
--
Expand Down Expand Up @@ -1864,6 +1904,14 @@ ALTER TABLE ONLY web.annotation_image
ADD CONSTRAINT annotation_image_pkey PRIMARY KEY (id);


--
-- Name: annotation_text annotation_text_pkey; Type: CONSTRAINT; Schema: web; Owner: openatlas
--

ALTER TABLE ONLY web.annotation_text
ADD CONSTRAINT annotation_text_pkey PRIMARY KEY (id);


--
-- Name: type_none_selectable entity_id_key; Type: CONSTRAINT; Schema: web; Owner: openatlas
--
Expand Down Expand Up @@ -2154,6 +2202,13 @@ CREATE TRIGGER update_modified BEFORE UPDATE ON model.gis FOR EACH ROW EXECUTE F
CREATE TRIGGER update_modified BEFORE UPDATE ON model.link FOR EACH ROW EXECUTE FUNCTION model.update_modified();


--
-- Name: annotation_text update_modified; Type: TRIGGER; Schema: web; Owner: openatlas
--

CREATE TRIGGER update_modified BEFORE UPDATE ON web.annotation_text FOR EACH ROW EXECUTE FUNCTION model.update_modified();


--
-- Name: group update_modified; Type: TRIGGER; Schema: web; Owner: openatlas
--
Expand Down Expand Up @@ -2424,6 +2479,30 @@ ALTER TABLE ONLY web.annotation_image
ADD CONSTRAINT annotation_image_user_id_fkey FOREIGN KEY (user_id) REFERENCES web."user"(id) ON UPDATE CASCADE ON DELETE SET NULL;


--
-- Name: annotation_text annotation_text_entity_id_fkey; Type: FK CONSTRAINT; Schema: web; Owner: openatlas
--

ALTER TABLE ONLY web.annotation_text
ADD CONSTRAINT annotation_text_entity_id_fkey FOREIGN KEY (entity_id) REFERENCES model.entity(id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: annotation_text annotation_text_source_id_fkey; Type: FK CONSTRAINT; Schema: web; Owner: openatlas
--

ALTER TABLE ONLY web.annotation_text
ADD CONSTRAINT annotation_text_source_id_fkey FOREIGN KEY (source_id) REFERENCES model.entity(id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: annotation_text annotation_text_user_id_fkey; Type: FK CONSTRAINT; Schema: web; Owner: openatlas
--

ALTER TABLE ONLY web.annotation_text
ADD CONSTRAINT annotation_text_user_id_fkey FOREIGN KEY (user_id) REFERENCES web."user"(id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: entity_profile_image entity_profile_image_entity_id_fkey; Type: FK CONSTRAINT; Schema: web; Owner: openatlas
--
Expand Down
34 changes: 34 additions & 0 deletions install/upgrade/text_annotation.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
BEGIN;

-- #2079: Text annotation
ALTER TABLE IF EXISTS ONLY web.annotation_text DROP CONSTRAINT IF EXISTS annotation_text_user_id_fkey;
ALTER TABLE IF EXISTS ONLY web.annotation_text DROP CONSTRAINT IF EXISTS annotation_text_source_id_fkey;
ALTER TABLE IF EXISTS ONLY web.annotation_text DROP CONSTRAINT IF EXISTS annotation_text_entity_id_fkey;
DROP TRIGGER IF EXISTS update_modified ON web.annotation_text;
ALTER TABLE IF EXISTS ONLY web.annotation_text DROP CONSTRAINT IF EXISTS annotation_text_pkey;
DROP TABLE IF EXISTS web.annotation_text;
DROP SEQUENCE IF EXISTS web.annotation_text_id_seq;

CREATE SEQUENCE web.annotation_text_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1;
ALTER TABLE web.annotation_text_id_seq OWNER TO openatlas;

CREATE TABLE web.annotation_text (
id integer DEFAULT nextval('web.annotation_text_id_seq'::regclass) NOT NULL,
source_id integer NOT NULL,
entity_id integer NOT NULL,
link_start integer NOT NULL,
link_end integer NOT NULL,
user_id integer,
text integer,
created timestamp without time zone DEFAULT now() NOT NULL,
modified timestamp without time zone
);
ALTER TABLE web.annotation_text OWNER TO openatlas;

ALTER TABLE ONLY web.annotation_text ADD CONSTRAINT annotation_text_pkey PRIMARY KEY (id);
CREATE TRIGGER update_modified BEFORE UPDATE ON web.annotation_text FOR EACH ROW EXECUTE FUNCTION model.update_modified();
ALTER TABLE ONLY web.annotation_text ADD CONSTRAINT annotation_text_entity_id_fkey FOREIGN KEY (entity_id) REFERENCES model.entity(id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY web.annotation_text ADD CONSTRAINT annotation_text_source_id_fkey FOREIGN KEY (source_id) REFERENCES model.entity(id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY web.annotation_text ADD CONSTRAINT annotation_text_user_id_fkey FOREIGN KEY (user_id) REFERENCES web."user"(id) ON UPDATE CASCADE ON DELETE CASCADE;

END;

0 comments on commit cb921ea

Please sign in to comment.