modify database schema

This commit is contained in:
Jay
2018-06-27 17:50:56 +08:00
parent 1f3057df69
commit 99e5a455cb
6 changed files with 347 additions and 50 deletions
+151 -22
View File
@@ -2,23 +2,33 @@
-- 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)
-- 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;
SET search_path = public, pg_catalog;
ALTER TABLE IF EXISTS ONLY public.page_group_rt DROP CONSTRAINT IF EXISTS page_group_rt_pageid_groupid_pk;
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 TABLE IF EXISTS public.page_group_rt;
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;
--
@@ -49,44 +59,163 @@ CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: page_group_rt; Type: TABLE; Schema: public; Owner: -
-- Name: facebook_page; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE page_group_rt (
CREATE TABLE public.facebook_page (
id integer NOT NULL,
groupid character varying(100) NOT NULL,
pageid character varying(200) NOT NULL,
groupid character varying(200) NOT NULL,
notify boolean DEFAULT false NOT NULL,
lastpost character varying(200) DEFAULT ''::character varying NOT NULL,
ctime timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
mtime timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
notify_tmpl character varying(500) DEFAULT ''::character varying 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 version_ctrl (
CREATE TABLE public.version_ctrl (
version integer NOT NULL,
ctime timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
querystr character varying(5000) DEFAULT ''::character varying NOT NULL
ctime timestamp with time zone DEFAULT now() NOT NULL,
querystr text DEFAULT ''::character varying NOT NULL
);
--
-- Name: page_group_rt page_group_rt_pageid_groupid_pk; Type: CONSTRAINT; Schema: public; Owner: -
-- Name: facebook_page id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY page_group_rt
ADD CONSTRAINT page_group_rt_pageid_groupid_pk PRIMARY KEY (pageid, groupid);
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);
--