mtfosbot/schema/main.sql
2018-06-27 17:50:56 +08:00

232 lines
6.1 KiB
SQL

--
-- PostgreSQL database dump
--
-- Dumped from database version 9.6.8
-- Dumped by pg_dump version 9.6.8
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;
ALTER TABLE IF EXISTS ONLY public.twitch_channel DROP CONSTRAINT IF EXISTS twitch_channel_line_group_id_fk;
ALTER TABLE IF EXISTS ONLY public.facebook_page DROP CONSTRAINT IF EXISTS facebook_page_line_group_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_pkey;
ALTER TABLE IF EXISTS ONLY public.line_group DROP CONSTRAINT IF EXISTS line_group_pkey;
ALTER TABLE IF EXISTS ONLY public.facebook_page DROP CONSTRAINT IF EXISTS facebook_page_pkey;
ALTER TABLE IF EXISTS public.twitch_channel ALTER COLUMN id DROP DEFAULT;
ALTER TABLE IF EXISTS public.facebook_page ALTER COLUMN id DROP DEFAULT;
DROP TABLE IF EXISTS public.version_ctrl;
DROP SEQUENCE IF EXISTS public.twitch_channel_id_seq;
DROP TABLE IF EXISTS public.twitch_channel;
DROP TABLE IF EXISTS public.line_group;
DROP SEQUENCE IF EXISTS public.facebook_page_id_seq;
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 default_tablespace = '';
SET default_with_oids = false;
--
-- Name: facebook_page; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.facebook_page (
id integer NOT NULL,
groupid character varying(100) NOT NULL,
pageid character varying(200) NOT NULL,
name character varying(100) NOT NULL,
lastpost character varying(100) DEFAULT ''::character varying NOT NULL,
tmpl character varying(200) DEFAULT ''::character varying NOT NULL,
ctime timestamp with time zone DEFAULT now() NOT NULL,
mtime timestamp with time zone DEFAULT now() NOT NULL
);
--
-- Name: facebook_page_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.facebook_page_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: facebook_page_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.facebook_page_id_seq OWNED BY public.facebook_page.id;
--
-- Name: line_group; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.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: twitch_channel; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.twitch_channel (
id integer NOT NULL,
twitchid 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,
groupid character varying(100) NOT NULL
);
--
-- Name: twitch_channel_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.twitch_channel_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: twitch_channel_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.twitch_channel_id_seq OWNED BY public.twitch_channel.id;
--
-- Name: version_ctrl; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.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 id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.facebook_page ALTER COLUMN id SET DEFAULT nextval('public.facebook_page_id_seq'::regclass);
--
-- Name: twitch_channel id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.twitch_channel ALTER COLUMN id SET DEFAULT nextval('public.twitch_channel_id_seq'::regclass);
--
-- Name: facebook_page facebook_page_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.facebook_page
ADD CONSTRAINT facebook_page_pkey PRIMARY KEY (id);
--
-- Name: line_group line_group_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.line_group
ADD CONSTRAINT line_group_pkey PRIMARY KEY (id);
--
-- Name: twitch_channel twitch_channel_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.twitch_channel
ADD CONSTRAINT twitch_channel_pkey PRIMARY KEY (id);
--
-- Name: line_group_name_uindex; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX line_group_name_uindex ON public.line_group USING btree (name);
--
-- Name: facebook_page facebook_page_line_group_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.facebook_page
ADD CONSTRAINT facebook_page_line_group_id_fk FOREIGN KEY (groupid) REFERENCES public.line_group(id) ON UPDATE CASCADE ON DELETE CASCADE;
--
-- Name: twitch_channel twitch_channel_line_group_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.twitch_channel
ADD CONSTRAINT twitch_channel_line_group_id_fk FOREIGN KEY (groupid) REFERENCES public.line_group(id);
--
-- Name: SCHEMA public; Type: ACL; Schema: -; Owner: -
--
GRANT ALL ON SCHEMA public TO PUBLIC;
--
-- PostgreSQL database dump complete
--