spec/dummy/db/structure.sql in landable-1.7.0 vs spec/dummy/db/structure.sql in landable-1.7.1.rc1

- old
+ new

@@ -102,10 +102,33 @@ END $_$; -- +-- Name: template_revision_ordinal(); Type: FUNCTION; Schema: dummy_landable; Owner: - +-- + +CREATE FUNCTION template_revision_ordinal() RETURNS trigger + LANGUAGE plpgsql + AS $_$ + BEGIN + + IF NEW.ordinal IS NOT NULL THEN + RAISE EXCEPTION $$Must not supply ordinal value manually.$$; + END IF; + + NEW.ordinal = (SELECT COALESCE(MAX(ordinal)+1,1) + FROM dummy_landable.template_revisions + WHERE template_id = NEW.template_id); + + RETURN NEW; + + END + $_$; + + +-- -- Name: tg_disallow(); Type: FUNCTION; Schema: dummy_landable; Owner: - -- CREATE FUNCTION tg_disallow() RETURNS trigger LANGUAGE plpgsql @@ -311,10 +334,31 @@ COMMENT ON TABLE pages IS 'Pages serve as a draft, where you can make changes, preview and save those changes without having to update the live page on the website. Pages also point to their published version, where applicable.'; -- +-- Name: template_revisions; Type: TABLE; Schema: dummy_landable; Owner: -; Tablespace: +-- + +CREATE TABLE template_revisions ( + template_revision_id uuid DEFAULT public.uuid_generate_v4() NOT NULL, + ordinal integer, + notes text, + is_minor boolean DEFAULT false, + is_published boolean DEFAULT true, + template_id uuid NOT NULL, + author_id uuid NOT NULL, + name text, + slug text, + body text, + description text, + created_at timestamp without time zone, + updated_at timestamp without time zone +); + + +-- -- Name: templates; Type: TABLE; Schema: dummy_landable; Owner: -; Tablespace: -- CREATE TABLE templates ( template_id uuid DEFAULT public.uuid_generate_v4() NOT NULL, @@ -325,11 +369,13 @@ thumbnail_url text, is_layout boolean DEFAULT false NOT NULL, created_at timestamp without time zone, updated_at timestamp without time zone, file text, - editable boolean DEFAULT true + editable boolean DEFAULT true, + published_revision_id uuid, + is_publishable boolean DEFAULT true ); -- -- Name: TABLE templates; Type: COMMENT; Schema: dummy_landable; Owner: - @@ -2043,10 +2089,18 @@ ALTER TABLE ONLY pages ADD CONSTRAINT pages_pkey PRIMARY KEY (page_id); -- +-- Name: template_revisions_pkey; Type: CONSTRAINT; Schema: dummy_landable; Owner: -; Tablespace: +-- + +ALTER TABLE ONLY template_revisions + ADD CONSTRAINT template_revisions_pkey PRIMARY KEY (template_revision_id); + + +-- -- Name: templates_pkey; Type: CONSTRAINT; Schema: dummy_landable; Owner: -; Tablespace: -- ALTER TABLE ONLY templates ADD CONSTRAINT templates_pkey PRIMARY KEY (template_id); @@ -3156,10 +3210,31 @@ CREATE TRIGGER dummy_landable_page_revisions__no_update BEFORE UPDATE OF notes, is_minor, page_id, author_id, created_at, ordinal, theme_id, status_code, category_id, redirect_url, body ON page_revisions FOR EACH STATEMENT EXECUTE PROCEDURE tg_disallow(); -- +-- Name: dummy_landable_template_revisions__bfr_insert; Type: TRIGGER; Schema: dummy_landable; Owner: - +-- + +CREATE TRIGGER dummy_landable_template_revisions__bfr_insert BEFORE INSERT ON template_revisions FOR EACH ROW EXECUTE PROCEDURE template_revision_ordinal(); + + +-- +-- Name: dummy_landable_template_revisions__no_delete; Type: TRIGGER; Schema: dummy_landable; Owner: - +-- + +CREATE TRIGGER dummy_landable_template_revisions__no_delete BEFORE DELETE ON template_revisions FOR EACH STATEMENT EXECUTE PROCEDURE tg_disallow(); + + +-- +-- Name: dummy_landable_template_revisions__no_update; Type: TRIGGER; Schema: dummy_landable; Owner: - +-- + +CREATE TRIGGER dummy_landable_template_revisions__no_update BEFORE UPDATE OF notes, is_minor, template_id, author_id, created_at, ordinal ON template_revisions FOR EACH STATEMENT EXECUTE PROCEDURE tg_disallow(); + + +-- -- Name: asset_id_fk; Type: FK CONSTRAINT; Schema: dummy_landable; Owner: - -- ALTER TABLE ONLY page_assets ADD CONSTRAINT asset_id_fk FOREIGN KEY (asset_id) REFERENCES assets(asset_id); @@ -3204,10 +3279,18 @@ ALTER TABLE ONLY page_revisions ADD CONSTRAINT author_id_fk FOREIGN KEY (author_id) REFERENCES authors(author_id); -- +-- Name: author_id_fk; Type: FK CONSTRAINT; Schema: dummy_landable; Owner: - +-- + +ALTER TABLE ONLY template_revisions + ADD CONSTRAINT author_id_fk FOREIGN KEY (author_id) REFERENCES authors(author_id); + + +-- -- Name: category_id_fk; Type: FK CONSTRAINT; Schema: dummy_landable; Owner: - -- ALTER TABLE ONLY pages ADD CONSTRAINT category_id_fk FOREIGN KEY (category_id) REFERENCES categories(category_id); @@ -3252,10 +3335,26 @@ ALTER TABLE ONLY pages ADD CONSTRAINT revision_id_fk FOREIGN KEY (published_revision_id) REFERENCES page_revisions(page_revision_id); -- +-- Name: template_id_fk; Type: FK CONSTRAINT; Schema: dummy_landable; Owner: - +-- + +ALTER TABLE ONLY template_revisions + ADD CONSTRAINT template_id_fk FOREIGN KEY (template_id) REFERENCES templates(template_id); + + +-- +-- Name: template_revision_id_fk; Type: FK CONSTRAINT; Schema: dummy_landable; Owner: - +-- + +ALTER TABLE ONLY templates + ADD CONSTRAINT template_revision_id_fk FOREIGN KEY (published_revision_id) REFERENCES template_revisions(template_revision_id); + + +-- -- Name: theme_id_fk; Type: FK CONSTRAINT; Schema: dummy_landable; Owner: - -- ALTER TABLE ONLY theme_assets ADD CONSTRAINT theme_id_fk FOREIGN KEY (theme_id) REFERENCES themes(theme_id); @@ -3689,11 +3788,11 @@ -- -- PostgreSQL database dump complete -- -SET search_path TO "$user", public; +SET search_path TO "$user",public; INSERT INTO schema_migrations (version) VALUES ('20130510221424'); INSERT INTO schema_migrations (version) VALUES ('20130909182713'); @@ -3732,5 +3831,7 @@ INSERT INTO schema_migrations (version) VALUES ('20140220170324'); INSERT INTO schema_migrations (version) VALUES ('20140220174630'); INSERT INTO schema_migrations (version) VALUES ('20140224205516'); + +INSERT INTO schema_migrations (version) VALUES ('20140509190128');