mtfosbot/schema/main.sql
2018-06-27 23:38:56 +08:00

233 lines
6.3 KiB
SQL

--
-- PostgreSQL database dump
--
-- Dumped from database version 10.2 (Debian 10.2-1.pgdg90+1)
-- Dumped by pg_dump version 10.2 (Debian 10.2-1.pgdg90+1)
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;
SET search_path = public, pg_catalog;
ALTER TABLE IF EXISTS ONLY public.line_twitch_rt DROP CONSTRAINT IF EXISTS line_twitch_rt_twitch_channel_id_fk;
ALTER TABLE IF EXISTS ONLY public.line_twitch_rt DROP CONSTRAINT IF EXISTS line_twitch_rt_line_group_id_fk;
ALTER TABLE IF EXISTS ONLY public.line_fb_rt DROP CONSTRAINT IF EXISTS line_fb_rt_line_group_id_fk;
ALTER TABLE IF EXISTS ONLY public.line_fb_rt DROP CONSTRAINT IF EXISTS line_fb_rt_facebook_page_id_fk;
DROP INDEX IF EXISTS public.line_group_name_uindex;
ALTER TABLE IF EXISTS ONLY public.twitch_channel DROP CONSTRAINT IF EXISTS twitch_channel_id_pk;
ALTER TABLE IF EXISTS ONLY public.line_twitch_rt DROP CONSTRAINT IF EXISTS line_twitch_rt_line_twitch_pk;
ALTER TABLE IF EXISTS ONLY public.line_group DROP CONSTRAINT IF EXISTS line_group_pkey;
ALTER TABLE IF EXISTS ONLY public.line_fb_rt DROP CONSTRAINT IF EXISTS line_fb_rt_facebook_line_pk;
ALTER TABLE IF EXISTS ONLY public.facebook_page DROP CONSTRAINT IF EXISTS facebook_page_id_pk;
DROP TABLE IF EXISTS public.version_ctrl;
DROP TABLE IF EXISTS public.twitch_channel;
DROP TABLE IF EXISTS public.line_twitch_rt;
DROP TABLE IF EXISTS public.line_group;
DROP TABLE IF EXISTS public.line_fb_rt;
DROP TABLE IF EXISTS public.facebook_page;
DROP EXTENSION IF EXISTS plpgsql;
DROP SCHEMA IF EXISTS public;
--
-- Name: public; Type: SCHEMA; Schema: -; Owner: -
--
CREATE SCHEMA public;
--
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON SCHEMA public IS 'standard public schema';
--
-- 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';
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: facebook_page; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE facebook_page (
id character varying(200) NOT NULL,
lastpost character varying(100) DEFAULT ''::character varying NOT NULL,
ctime timestamp with time zone DEFAULT now() NOT NULL,
mtime timestamp with time zone DEFAULT now() NOT NULL
);
--
-- Name: line_fb_rt; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE line_fb_rt (
line character varying(100) NOT NULL,
facebook character varying(200) NOT NULL,
tmpl character varying(300) DEFAULT ''::character varying NOT NULL
);
--
-- Name: line_group; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE line_group (
id character varying(100) NOT NULL,
name character varying(200) NOT NULL,
notify boolean DEFAULT false NOT NULL,
ctime timestamp with time zone DEFAULT now() NOT NULL,
mtime timestamp with time zone DEFAULT now() NOT NULL,
owner character varying(100) DEFAULT ''::character varying NOT NULL
);
--
-- Name: line_twitch_rt; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE line_twitch_rt (
line character varying(100) NOT NULL,
twitch character varying(100) NOT NULL,
tmpl character varying(300) DEFAULT ''::character varying NOT NULL
);
--
-- Name: twitch_channel; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE twitch_channel (
id character varying(100) NOT NULL,
name character varying(200) NOT NULL,
type character varying(100) DEFAULT ''::character varying NOT NULL,
ctime timestamp with time zone DEFAULT now() NOT NULL,
mtime timestamp with time zone DEFAULT now() NOT NULL
);
--
-- Name: version_ctrl; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE version_ctrl (
version integer NOT NULL,
ctime timestamp with time zone DEFAULT now() NOT NULL,
querystr text DEFAULT ''::character varying NOT NULL
);
--
-- Name: facebook_page facebook_page_id_pk; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY facebook_page
ADD CONSTRAINT facebook_page_id_pk PRIMARY KEY (id);
--
-- Name: line_fb_rt line_fb_rt_facebook_line_pk; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY line_fb_rt
ADD CONSTRAINT line_fb_rt_facebook_line_pk PRIMARY KEY (facebook, line);
--
-- Name: line_group line_group_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY line_group
ADD CONSTRAINT line_group_pkey PRIMARY KEY (id);
--
-- Name: line_twitch_rt line_twitch_rt_line_twitch_pk; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY line_twitch_rt
ADD CONSTRAINT line_twitch_rt_line_twitch_pk PRIMARY KEY (line, twitch);
--
-- Name: twitch_channel twitch_channel_id_pk; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY twitch_channel
ADD CONSTRAINT twitch_channel_id_pk PRIMARY KEY (id);
--
-- Name: line_group_name_uindex; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX line_group_name_uindex ON line_group USING btree (name);
--
-- Name: line_fb_rt line_fb_rt_facebook_page_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY line_fb_rt
ADD CONSTRAINT line_fb_rt_facebook_page_id_fk FOREIGN KEY (facebook) REFERENCES facebook_page(id) ON DELETE CASCADE;
--
-- Name: line_fb_rt line_fb_rt_line_group_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY line_fb_rt
ADD CONSTRAINT line_fb_rt_line_group_id_fk FOREIGN KEY (line) REFERENCES line_group(id) ON DELETE CASCADE;
--
-- Name: line_twitch_rt line_twitch_rt_line_group_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY line_twitch_rt
ADD CONSTRAINT line_twitch_rt_line_group_id_fk FOREIGN KEY (line) REFERENCES line_group(id) ON DELETE CASCADE;
--
-- Name: line_twitch_rt line_twitch_rt_twitch_channel_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY line_twitch_rt
ADD CONSTRAINT line_twitch_rt_twitch_channel_id_fk FOREIGN KEY (twitch) REFERENCES twitch_channel(id) ON DELETE CASCADE;
--
-- Name: SCHEMA public; Type: ACL; Schema: -; Owner: -
--
GRANT ALL ON SCHEMA public TO PUBLIC;
--
-- PostgreSQL database dump complete
--