--
-- PostgreSQL database dump
--

-- Dumped from database version 13.0 (Ubuntu 13.0-1.pgdg20.04+1)
-- Dumped by pg_dump version 13.0 (Ubuntu 13.0-1.pgdg20.04+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;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

--
-- Name: backlog_lastmsgid_update(); Type: FUNCTION; Schema: public; Owner: quasselcore
--

CREATE FUNCTION public.backlog_lastmsgid_update() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    BEGIN
        UPDATE buffer
        SET lastmsgid = new.messageid
        WHERE buffer.bufferid = new.bufferid
            AND buffer.lastmsgid < new.messageid;
        RETURN new;
    END
$$;


ALTER FUNCTION public.backlog_lastmsgid_update() OWNER TO quasselcore;

--
-- Name: populate_lastmsgid(); Type: FUNCTION; Schema: public; Owner: quasselcore
--

CREATE FUNCTION public.populate_lastmsgid() RETURNS void
    LANGUAGE plpgsql
    AS $$
DECLARE
        i buffer%rowtype;
BEGIN
        FOR i IN SELECT * FROM buffer
        LOOP
                UPDATE buffer
                        SET lastmsgid = (
                                SELECT backlog.messageid
                                FROM backlog
                                WHERE backlog.bufferid = i.bufferid
                                ORDER BY messageid DESC LIMIT 1
                        )
                        WHERE buffer.bufferid = i.bufferid;
        END LOOP;
        RETURN;
END
$$;


ALTER FUNCTION public.populate_lastmsgid() OWNER TO quasselcore;

SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- Name: backlog; Type: TABLE; Schema: public; Owner: quasselcore
--

CREATE TABLE public.backlog (
    messageid bigint NOT NULL,
    "time" timestamp without time zone NOT NULL,
    bufferid integer NOT NULL,
    type integer NOT NULL,
    flags integer NOT NULL,
    senderid bigint NOT NULL,
    senderprefixes text,
    message text
);


ALTER TABLE public.backlog OWNER TO quasselcore;

--
-- Name: backlog_messageid_seq; Type: SEQUENCE; Schema: public; Owner: quasselcore
--

CREATE SEQUENCE public.backlog_messageid_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 100;


ALTER TABLE public.backlog_messageid_seq OWNER TO quasselcore;

--
-- Name: backlog_messageid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: quasselcore
--

ALTER SEQUENCE public.backlog_messageid_seq OWNED BY public.backlog.messageid;


--
-- Name: buffer; Type: TABLE; Schema: public; Owner: quasselcore
--

CREATE TABLE public.buffer (
    bufferid integer NOT NULL,
    userid integer NOT NULL,
    groupid integer,
    networkid integer NOT NULL,
    buffername character varying(128) NOT NULL,
    buffercname character varying(128) NOT NULL,
    buffertype integer DEFAULT 0 NOT NULL,
    lastmsgid bigint DEFAULT 0 NOT NULL,
    lastseenmsgid bigint DEFAULT 0 NOT NULL,
    markerlinemsgid bigint DEFAULT 0 NOT NULL,
    bufferactivity integer DEFAULT 0 NOT NULL,
    highlightcount integer DEFAULT 0 NOT NULL,
    key character varying(128),
    joined boolean DEFAULT false NOT NULL,
    cipher text,
    CONSTRAINT buffer_check CHECK ((lastseenmsgid <= lastmsgid))
);


ALTER TABLE public.buffer OWNER TO quasselcore;

--
-- Name: buffer_bufferid_seq; Type: SEQUENCE; Schema: public; Owner: quasselcore
--

CREATE SEQUENCE public.buffer_bufferid_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.buffer_bufferid_seq OWNER TO quasselcore;

--
-- Name: buffer_bufferid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: quasselcore
--

ALTER SEQUENCE public.buffer_bufferid_seq OWNED BY public.buffer.bufferid;


--
-- Name: core_state; Type: TABLE; Schema: public; Owner: quasselcore
--

CREATE TABLE public.core_state (
    key text NOT NULL,
    value bytea
);


ALTER TABLE public.core_state OWNER TO quasselcore;

--
-- Name: coreinfo; Type: TABLE; Schema: public; Owner: quasselcore
--

CREATE TABLE public.coreinfo (
    key text NOT NULL,
    value text
);


ALTER TABLE public.coreinfo OWNER TO quasselcore;

--
-- Name: identity; Type: TABLE; Schema: public; Owner: quasselcore
--

CREATE TABLE public.identity (
    identityid integer NOT NULL,
    userid integer NOT NULL,
    identityname character varying(64) NOT NULL,
    realname character varying(128) NOT NULL,
    awaynick character varying(64),
    awaynickenabled boolean DEFAULT false NOT NULL,
    awayreason character varying(256),
    awayreasonenabled boolean DEFAULT false NOT NULL,
    autoawayenabled boolean DEFAULT false NOT NULL,
    autoawaytime integer NOT NULL,
    autoawayreason character varying(256),
    autoawayreasonenabled boolean DEFAULT false NOT NULL,
    detachawayenabled boolean DEFAULT false NOT NULL,
    detachawayreason character varying(256),
    detachawayreasonenabled boolean DEFAULT false NOT NULL,
    ident character varying(64),
    kickreason character varying(256),
    partreason character varying(256),
    quitreason character varying(256),
    sslcert bytea,
    sslkey bytea
);


ALTER TABLE public.identity OWNER TO quasselcore;

--
-- Name: identity_identityid_seq; Type: SEQUENCE; Schema: public; Owner: quasselcore
--

CREATE SEQUENCE public.identity_identityid_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.identity_identityid_seq OWNER TO quasselcore;

--
-- Name: identity_identityid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: quasselcore
--

ALTER SEQUENCE public.identity_identityid_seq OWNED BY public.identity.identityid;


--
-- Name: identity_nick; Type: TABLE; Schema: public; Owner: quasselcore
--

CREATE TABLE public.identity_nick (
    nickid integer NOT NULL,
    identityid integer NOT NULL,
    nick character varying(64) NOT NULL
);


ALTER TABLE public.identity_nick OWNER TO quasselcore;

--
-- Name: identity_nick_nickid_seq; Type: SEQUENCE; Schema: public; Owner: quasselcore
--

CREATE SEQUENCE public.identity_nick_nickid_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.identity_nick_nickid_seq OWNER TO quasselcore;

--
-- Name: identity_nick_nickid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: quasselcore
--

ALTER SEQUENCE public.identity_nick_nickid_seq OWNED BY public.identity_nick.nickid;


--
-- Name: ircserver; Type: TABLE; Schema: public; Owner: quasselcore
--

CREATE TABLE public.ircserver (
    serverid integer NOT NULL,
    userid integer NOT NULL,
    networkid integer NOT NULL,
    hostname character varying(128) NOT NULL,
    port integer DEFAULT 6667 NOT NULL,
    password character varying(64),
    ssl boolean DEFAULT false NOT NULL,
    sslversion integer DEFAULT 0 NOT NULL,
    useproxy boolean DEFAULT false NOT NULL,
    proxytype integer DEFAULT 0 NOT NULL,
    proxyhost character varying(128) DEFAULT 'localhost'::character varying NOT NULL,
    proxyport integer DEFAULT 8080 NOT NULL,
    proxyuser character varying(64),
    proxypass character varying(64),
    sslverify boolean DEFAULT false NOT NULL
);


ALTER TABLE public.ircserver OWNER TO quasselcore;

--
-- Name: ircserver_serverid_seq; Type: SEQUENCE; Schema: public; Owner: quasselcore
--

CREATE SEQUENCE public.ircserver_serverid_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.ircserver_serverid_seq OWNER TO quasselcore;

--
-- Name: ircserver_serverid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: quasselcore
--

ALTER SEQUENCE public.ircserver_serverid_seq OWNED BY public.ircserver.serverid;


--
-- Name: network; Type: TABLE; Schema: public; Owner: quasselcore
--

CREATE TABLE public.network (
    networkid integer NOT NULL,
    userid integer NOT NULL,
    networkname character varying(32) NOT NULL,
    identityid integer,
    encodingcodec character varying(32) DEFAULT 'ISO-8859-15'::character varying NOT NULL,
    decodingcodec character varying(32) DEFAULT 'ISO-8859-15'::character varying NOT NULL,
    servercodec character varying(32),
    userandomserver boolean DEFAULT false NOT NULL,
    perform text,
    useautoidentify boolean DEFAULT false NOT NULL,
    autoidentifyservice character varying(128),
    autoidentifypassword character varying(128),
    usesasl boolean DEFAULT false NOT NULL,
    saslaccount character varying(128),
    saslpassword character varying(128),
    useautoreconnect boolean DEFAULT true NOT NULL,
    autoreconnectinterval integer DEFAULT 0 NOT NULL,
    autoreconnectretries integer DEFAULT 0 NOT NULL,
    unlimitedconnectretries boolean DEFAULT false NOT NULL,
    rejoinchannels boolean DEFAULT false NOT NULL,
    connected boolean DEFAULT false NOT NULL,
    usermode character varying(32),
    awaymessage character varying(256),
    attachperform text,
    detachperform text,
    usecustomessagerate boolean DEFAULT false NOT NULL,
    messagerateburstsize integer DEFAULT 5 NOT NULL,
    messageratedelay integer DEFAULT 2200 NOT NULL,
    unlimitedmessagerate boolean DEFAULT false NOT NULL
);


ALTER TABLE public.network OWNER TO quasselcore;

--
-- Name: network_networkid_seq; Type: SEQUENCE; Schema: public; Owner: quasselcore
--

CREATE SEQUENCE public.network_networkid_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.network_networkid_seq OWNER TO quasselcore;

--
-- Name: network_networkid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: quasselcore
--

ALTER SEQUENCE public.network_networkid_seq OWNED BY public.network.networkid;


--
-- Name: quasseluser; Type: TABLE; Schema: public; Owner: quasselcore
--

CREATE TABLE public.quasseluser (
    userid integer NOT NULL,
    username character varying(64) NOT NULL,
    password text NOT NULL,
    hashversion integer DEFAULT 0 NOT NULL,
    authenticator character varying(64) DEFAULT 'Database'::character varying NOT NULL
);


ALTER TABLE public.quasseluser OWNER TO quasselcore;

--
-- Name: quasseluser_userid_seq; Type: SEQUENCE; Schema: public; Owner: quasselcore
--

CREATE SEQUENCE public.quasseluser_userid_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.quasseluser_userid_seq OWNER TO quasselcore;

--
-- Name: quasseluser_userid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: quasselcore
--

ALTER SEQUENCE public.quasseluser_userid_seq OWNED BY public.quasseluser.userid;


--
-- Name: sender; Type: TABLE; Schema: public; Owner: quasselcore
--

CREATE TABLE public.sender (
    senderid bigint NOT NULL,
    sender character varying(128) NOT NULL,
    realname text,
    avatarurl text
);


ALTER TABLE public.sender OWNER TO quasselcore;

--
-- Name: sender_senderid_seq; Type: SEQUENCE; Schema: public; Owner: quasselcore
--

CREATE SEQUENCE public.sender_senderid_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 100;


ALTER TABLE public.sender_senderid_seq OWNER TO quasselcore;

--
-- Name: sender_senderid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: quasselcore
--

ALTER SEQUENCE public.sender_senderid_seq OWNED BY public.sender.senderid;


--
-- Name: user_setting; Type: TABLE; Schema: public; Owner: quasselcore
--

CREATE TABLE public.user_setting (
    userid integer NOT NULL,
    settingname text NOT NULL,
    settingvalue bytea
);


ALTER TABLE public.user_setting OWNER TO quasselcore;

--
-- Name: backlog messageid; Type: DEFAULT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.backlog ALTER COLUMN messageid SET DEFAULT nextval('public.backlog_messageid_seq'::regclass);


--
-- Name: buffer bufferid; Type: DEFAULT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.buffer ALTER COLUMN bufferid SET DEFAULT nextval('public.buffer_bufferid_seq'::regclass);


--
-- Name: identity identityid; Type: DEFAULT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.identity ALTER COLUMN identityid SET DEFAULT nextval('public.identity_identityid_seq'::regclass);


--
-- Name: identity_nick nickid; Type: DEFAULT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.identity_nick ALTER COLUMN nickid SET DEFAULT nextval('public.identity_nick_nickid_seq'::regclass);


--
-- Name: ircserver serverid; Type: DEFAULT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.ircserver ALTER COLUMN serverid SET DEFAULT nextval('public.ircserver_serverid_seq'::regclass);


--
-- Name: network networkid; Type: DEFAULT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.network ALTER COLUMN networkid SET DEFAULT nextval('public.network_networkid_seq'::regclass);


--
-- Name: quasseluser userid; Type: DEFAULT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.quasseluser ALTER COLUMN userid SET DEFAULT nextval('public.quasseluser_userid_seq'::regclass);


--
-- Name: sender senderid; Type: DEFAULT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.sender ALTER COLUMN senderid SET DEFAULT nextval('public.sender_senderid_seq'::regclass);


--
-- Data for Name: backlog; Type: TABLE DATA; Schema: public; Owner: quasselcore
--

COPY public.backlog (messageid, "time", bufferid, type, flags, senderid, senderprefixes, message) FROM stdin;
\.


--
-- Data for Name: buffer; Type: TABLE DATA; Schema: public; Owner: quasselcore
--

COPY public.buffer (bufferid, userid, groupid, networkid, buffername, buffercname, buffertype, lastmsgid, lastseenmsgid, markerlinemsgid, bufferactivity, highlightcount, key, joined, cipher) FROM stdin;
\.


--
-- Data for Name: core_state; Type: TABLE DATA; Schema: public; Owner: quasselcore
--

COPY public.core_state (key, value) FROM stdin;
\.


--
-- Data for Name: coreinfo; Type: TABLE DATA; Schema: public; Owner: quasselcore
--

COPY public.coreinfo (key, value) FROM stdin;
schemaversion   29
\.


--
-- Data for Name: identity; Type: TABLE DATA; Schema: public; Owner: quasselcore
--

COPY public.identity (identityid, userid, identityname, realname, awaynick, awaynickenabled, awayreason, awayreasonenabled, autoawayenabled, autoawaytime, autoawayreason, autoawayreasonenabled, detachawayenabled, detachawayreason, detachawayreasonenabled, ident, kickreason, partreason, quitreason, sslcert, sslkey) FROM stdin;
\.


--
-- Data for Name: identity_nick; Type: TABLE DATA; Schema: public; Owner: quasselcore
--

COPY public.identity_nick (nickid, identityid, nick) FROM stdin;
\.


--
-- Data for Name: ircserver; Type: TABLE DATA; Schema: public; Owner: quasselcore
--

COPY public.ircserver (serverid, userid, networkid, hostname, port, password, ssl, sslversion, useproxy, proxytype, proxyhost, proxyport, proxyuser, proxypass, sslverify) FROM stdin;
\.


--
-- Data for Name: network; Type: TABLE DATA; Schema: public; Owner: quasselcore
--

COPY public.network (networkid, userid, networkname, identityid, encodingcodec, decodingcodec, servercodec, userandomserver, perform, useautoidentify, autoidentifyservice, autoidentifypassword, usesasl, saslaccount, saslpassword, useautoreconnect, autoreconnectinterval, autoreconnectretries, unlimitedconnectretries, rejoinchannels, connected, usermode, awaymessage, attachperform, detachperform, usecustomessagerate, messagerateburstsize, messageratedelay, unlimitedmessagerate) FROM stdin;
\.


--
-- Data for Name: quasseluser; Type: TABLE DATA; Schema: public; Owner: quasselcore
--

COPY public.quasseluser (userid, username, password, hashversion, authenticator) FROM stdin;
\.


--
-- Data for Name: sender; Type: TABLE DATA; Schema: public; Owner: quasselcore
--

COPY public.sender (senderid, sender, realname, avatarurl) FROM stdin;
\.


--
-- Data for Name: user_setting; Type: TABLE DATA; Schema: public; Owner: quasselcore
--

COPY public.user_setting (userid, settingname, settingvalue) FROM stdin;
\.


--
-- Name: backlog_messageid_seq; Type: SEQUENCE SET; Schema: public; Owner: quasselcore
--

SELECT pg_catalog.setval('public.backlog_messageid_seq', 1, false);


--
-- Name: buffer_bufferid_seq; Type: SEQUENCE SET; Schema: public; Owner: quasselcore
--

SELECT pg_catalog.setval('public.buffer_bufferid_seq', 1, false);


--
-- Name: identity_identityid_seq; Type: SEQUENCE SET; Schema: public; Owner: quasselcore
--

SELECT pg_catalog.setval('public.identity_identityid_seq', 1, false);


--
-- Name: identity_nick_nickid_seq; Type: SEQUENCE SET; Schema: public; Owner: quasselcore
--

SELECT pg_catalog.setval('public.identity_nick_nickid_seq', 1, false);


--
-- Name: ircserver_serverid_seq; Type: SEQUENCE SET; Schema: public; Owner: quasselcore
--

SELECT pg_catalog.setval('public.ircserver_serverid_seq', 1, false);


--
-- Name: network_networkid_seq; Type: SEQUENCE SET; Schema: public; Owner: quasselcore
--

SELECT pg_catalog.setval('public.network_networkid_seq', 1, false);


--
-- Name: quasseluser_userid_seq; Type: SEQUENCE SET; Schema: public; Owner: quasselcore
--

SELECT pg_catalog.setval('public.quasseluser_userid_seq', 1, false);


--
-- Name: sender_senderid_seq; Type: SEQUENCE SET; Schema: public; Owner: quasselcore
--

SELECT pg_catalog.setval('public.sender_senderid_seq', 1, false);


--
-- Name: backlog backlog_pkey; Type: CONSTRAINT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.backlog
    ADD CONSTRAINT backlog_pkey PRIMARY KEY (messageid);


--
-- Name: buffer buffer_pkey; Type: CONSTRAINT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.buffer
    ADD CONSTRAINT buffer_pkey PRIMARY KEY (bufferid);


--
-- Name: buffer buffer_userid_networkid_buffercname_key; Type: CONSTRAINT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.buffer
    ADD CONSTRAINT buffer_userid_networkid_buffercname_key UNIQUE (userid, networkid, buffercname);


--
-- Name: core_state core_state_pkey; Type: CONSTRAINT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.core_state
    ADD CONSTRAINT core_state_pkey PRIMARY KEY (key);


--
-- Name: coreinfo coreinfo_pkey; Type: CONSTRAINT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.coreinfo
    ADD CONSTRAINT coreinfo_pkey PRIMARY KEY (key);


--
-- Name: identity_nick identity_nick_identityid_nick_key; Type: CONSTRAINT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.identity_nick
    ADD CONSTRAINT identity_nick_identityid_nick_key UNIQUE (identityid, nick);


--
-- Name: identity_nick identity_nick_pkey; Type: CONSTRAINT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.identity_nick
    ADD CONSTRAINT identity_nick_pkey PRIMARY KEY (nickid);


--
-- Name: identity identity_pkey; Type: CONSTRAINT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.identity
    ADD CONSTRAINT identity_pkey PRIMARY KEY (identityid);


--
-- Name: identity identity_userid_identityname_key; Type: CONSTRAINT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.identity
    ADD CONSTRAINT identity_userid_identityname_key UNIQUE (userid, identityname);


--
-- Name: ircserver ircserver_pkey; Type: CONSTRAINT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.ircserver
    ADD CONSTRAINT ircserver_pkey PRIMARY KEY (serverid);


--
-- Name: network network_pkey; Type: CONSTRAINT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.network
    ADD CONSTRAINT network_pkey PRIMARY KEY (networkid);


--
-- Name: network network_userid_networkname_key; Type: CONSTRAINT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.network
    ADD CONSTRAINT network_userid_networkname_key UNIQUE (userid, networkname);


--
-- Name: quasseluser quasseluser_pkey; Type: CONSTRAINT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.quasseluser
    ADD CONSTRAINT quasseluser_pkey PRIMARY KEY (userid);


--
-- Name: quasseluser quasseluser_username_key; Type: CONSTRAINT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.quasseluser
    ADD CONSTRAINT quasseluser_username_key UNIQUE (username);


--
-- Name: sender sender_pkey; Type: CONSTRAINT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.sender
    ADD CONSTRAINT sender_pkey PRIMARY KEY (senderid);


--
-- Name: user_setting user_setting_pkey; Type: CONSTRAINT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.user_setting
    ADD CONSTRAINT user_setting_pkey PRIMARY KEY (userid, settingname);


--
-- Name: backlog_bufferid_idx; Type: INDEX; Schema: public; Owner: quasselcore
--

CREATE INDEX backlog_bufferid_idx ON public.backlog USING btree (bufferid, messageid DESC);


--
-- Name: sender_sender_realname_avatarurl_uindex; Type: INDEX; Schema: public; Owner: quasselcore
--

CREATE UNIQUE INDEX sender_sender_realname_avatarurl_uindex ON public.sender USING btree (sender, realname, avatarurl);


--
-- Name: backlog backlog_lastmsgid_update_trigger; Type: TRIGGER; Schema: public; Owner: quasselcore
--

CREATE TRIGGER backlog_lastmsgid_update_trigger AFTER INSERT OR UPDATE ON public.backlog FOR EACH ROW EXECUTE FUNCTION public.backlog_lastmsgid_update();


--
-- Name: backlog backlog_bufferid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.backlog
    ADD CONSTRAINT backlog_bufferid_fkey FOREIGN KEY (bufferid) REFERENCES public.buffer(bufferid) ON DELETE CASCADE;


--
-- Name: backlog backlog_senderid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.backlog
    ADD CONSTRAINT backlog_senderid_fkey FOREIGN KEY (senderid) REFERENCES public.sender(senderid) ON DELETE SET NULL;


--
-- Name: buffer buffer_networkid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.buffer
    ADD CONSTRAINT buffer_networkid_fkey FOREIGN KEY (networkid) REFERENCES public.network(networkid) ON DELETE CASCADE;


--
-- Name: buffer buffer_userid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.buffer
    ADD CONSTRAINT buffer_userid_fkey FOREIGN KEY (userid) REFERENCES public.quasseluser(userid) ON DELETE CASCADE;


--
-- Name: identity_nick identity_nick_identityid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.identity_nick
    ADD CONSTRAINT identity_nick_identityid_fkey FOREIGN KEY (identityid) REFERENCES public.identity(identityid) ON DELETE CASCADE;


--
-- Name: identity identity_userid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.identity
    ADD CONSTRAINT identity_userid_fkey FOREIGN KEY (userid) REFERENCES public.quasseluser(userid) ON DELETE CASCADE;


--
-- Name: ircserver ircserver_networkid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.ircserver
    ADD CONSTRAINT ircserver_networkid_fkey FOREIGN KEY (networkid) REFERENCES public.network(networkid) ON DELETE CASCADE;


--
-- Name: ircserver ircserver_userid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.ircserver
    ADD CONSTRAINT ircserver_userid_fkey FOREIGN KEY (userid) REFERENCES public.quasseluser(userid) ON DELETE CASCADE;


--
-- Name: network network_identityid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.network
    ADD CONSTRAINT network_identityid_fkey FOREIGN KEY (identityid) REFERENCES public.identity(identityid) ON DELETE SET NULL;


--
-- Name: network network_userid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.network
    ADD CONSTRAINT network_userid_fkey FOREIGN KEY (userid) REFERENCES public.quasseluser(userid) ON DELETE CASCADE;


--
-- Name: user_setting user_setting_userid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: quasselcore
--

ALTER TABLE ONLY public.user_setting
    ADD CONSTRAINT user_setting_userid_fkey FOREIGN KEY (userid) REFERENCES public.quasseluser(userid) ON DELETE CASCADE;


--
-- PostgreSQL database dump complete
--