-- Downloaded from: https://github.com/bartr/agency/blob/9e8f7185023b3616a144f56b0bbbc0f7cb89b37d/sql/cnp.sql
--
-- PostgreSQL database dump
--

-- Dumped from database version 13.4 (Debian 13.4-4.pgdg110+1)
-- Dumped by pg_dump version 13.4 (Debian 13.4-4.pgdg110+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;
SET default_tablespace = '';
SET default_table_access_method = heap;

--
-- Name: update_modified(); Type: FUNCTION; Schema: public; Owner: root
--

CREATE FUNCTION public.update_modified() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
  NEW.modified_ = now(); 
  RETURN NEW;
END;
$$;


ALTER FUNCTION public.update_modified() OWNER TO root;

--
-- Name: children; Type: TABLE; Schema: public; Owner: root
--

CREATE TABLE public.children (
    parentid integer NOT NULL,
    childid integer NOT NULL,
    sortorder integer DEFAULT 100
);


ALTER TABLE public.children OWNER TO root;

--
-- Name: links; Type: TABLE; Schema: public; Owner: root
--

CREATE TABLE public.links (
    id integer NOT NULL,
    path character varying(400) NOT NULL,
    type integer NOT NULL,
    description character varying(64000) NOT NULL,
    owner character varying(100) NOT NULL,
    target character varying(400) DEFAULT ''::character varying NOT NULL,
    content character varying(64000) DEFAULT ''::character varying NOT NULL,
    isprivate boolean DEFAULT false NOT NULL,
    created_ timestamp(0) with time zone DEFAULT now() NOT NULL,
    modified_ timestamp(0) with time zone DEFAULT now() NOT NULL,
    title character varying(400) DEFAULT ''::character varying NOT NULL,
    tags json DEFAULT '[]'::json NOT NULL,
    template character varying(16000) DEFAULT ''::character varying NOT NULL,
    html character varying(64000) DEFAULT ''::character varying NOT NULL,
    orderby character varying(8000) DEFAULT ''::character varying NOT NULL,
    tenant character varying(100) DEFAULT '*'::character varying NOT NULL,
    sortorder integer DEFAULT 100 NOT NULL,
    theme character varying(400) DEFAULT 'blue'::character varying NOT NULL,
    title2 character varying(400) DEFAULT ''::character varying NOT NULL,
    thumbnail character varying(400) DEFAULT ''::character varying,
    background character varying(400) DEFAULT ''::character varying,
    facebook character varying(200) DEFAULT ''::character varying,
    github character varying(200) DEFAULT ''::character varying,
    instagram character varying(200) DEFAULT ''::character varying,
    linkedin character varying(200) DEFAULT ''::character varying,
    twitter character varying(200) DEFAULT ''::character varying,
    youtube character varying(200) DEFAULT ''::character varying,
    web character varying(200) DEFAULT ''::character varying
);


ALTER TABLE public.links OWNER TO root;

--
-- Name: links_id_seq; Type: SEQUENCE; Schema: public; Owner: root
--

ALTER TABLE public.links ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.links_id_seq
    START WITH 101
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: logs; Type: TABLE; Schema: public; Owner: root
--

CREATE TABLE public.logs (
    id integer NOT NULL,
    date timestamp(3) with time zone NOT NULL,
    statuscode integer NOT NULL,
    path character varying(400) NOT NULL,
    duration integer NOT NULL,
    contentlength integer NOT NULL,
    method character varying(10) NOT NULL,
    host character varying(100) DEFAULT ''::character varying NOT NULL,
    ipaddress character varying(20) DEFAULT ''::character varying NOT NULL,
    querystring character varying(400) DEFAULT ''::character varying NOT NULL,
    referrer character varying(400) DEFAULT ''::character varying NOT NULL,
    useragent character varying(400) DEFAULT ''::character varying NOT NULL,
    ismobile boolean DEFAULT false NOT NULL,
    userid character varying(100) DEFAULT ''::character varying NOT NULL,
    category character varying(100) DEFAULT ''::character varying NOT NULL,
    tag character varying(100) DEFAULT ''::character varying NOT NULL
);


ALTER TABLE public.logs OWNER TO root;

--
-- Name: logs_id_seq; Type: SEQUENCE; Schema: public; Owner: root
--

ALTER TABLE public.logs ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.logs_id_seq
    START WITH 101
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: users; Type: TABLE; Schema: public; Owner: root
--

CREATE TABLE public.users (
    id character varying(50) NOT NULL,
    isadmin boolean DEFAULT false NOT NULL,
    token character varying(200) DEFAULT ''::character varying NOT NULL,
    cookie character varying(200) DEFAULT ''::character varying NOT NULL,
    github character varying(200) DEFAULT ''::character varying NOT NULL,
    linkedin character varying(200) DEFAULT ''::character varying NOT NULL,
    twitter character varying(200) DEFAULT ''::character varying NOT NULL,
    facebook character varying(200) DEFAULT ''::character varying,
    instagram character varying(200) DEFAULT ''::character varying,
    youtube character varying(200) DEFAULT ''::character varying
);


ALTER TABLE public.users OWNER TO root;

--
-- Data for Name: children; Type: TABLE DATA; Schema: public; Owner: root
--

COPY public.children (parentid, childid, sortorder) FROM stdin;
0	101	1
0	103	100
0	104	100
101	102	100
\.


--
-- Data for Name: links; Type: TABLE DATA; Schema: public; Owner: root
--

COPY public.links (id, path, type, description, owner, target, content, isprivate, created_, modified_, title, tags, template, html, orderby, tenant, sortorder, theme, title2, thumbnail, background, facebook, github, instagram, linkedin, twitter, youtube, web) FROM stdin;
0	/	0	<h1>Welcome to CNP Labs</h1>Under construction ...	cnp		Welcome to CNP Labs Under construction	f	2021-11-09 21:02:18+00	2021-11-09 21:28:38+00	CNP Labs	[]	cnp-tree			cnp.dev	100	orange					https://cnp.dev/github					
1	/github	1	CNP Labs GitHub	cnp	https://github.com/cnp-labs	/github\nCNP Labs GitHub\nhttps://github.com/cnp-labs\nCNP Labs GitHub	f	2021-11-09 21:15:16+00	2021-11-09 21:28:38+00	CNP Labs GitHub	[]				cnp.dev	100	orange										
2	/gh	1	CNP Labs GitHub	cnp	https://github.com/cnp-labs	/gh\nCNP Labs GitHub\nhttps://github.com/cnp-labs\nCNP Labs GitHub	f	2021-11-09 21:15:31+00	2021-11-09 21:28:38+00	CNP Labs GitHub	[]				cnp.dev	100	orange										
101	/demos	0	Demo videos	cnp		/demos\nDemo Videos\nDemo videos	f	2021-11-09 21:10:32+00	2021-11-09 21:30:16+00	Demo Videos	[]	cnp-tree			cnp.dev	1	orange	CNP Labs									
102	/demos/devx	1	CNP Labs Developer Experience Demo Video	cnp	https://cnp.dev/cnp/content/CNP-Labs-DevX.mp4	DevX Demo CNP Labs Developer Experience Demo Video	f	2021-11-09 21:11:25+00	2021-11-09 21:28:38+00	DevX Demo	[]				cnp.dev	100	orange										
103	/blog	0	CNP Labs Blog	cnp		/blog\nOur Blog\nCNP Labs Blog	f	2021-11-09 21:24:12+00	2021-11-09 21:28:57+00	Our Blog	[]	cnp-tree	Under Construction		cnp.dev	100	orange	CNP Labs									
104	/about	0	About CNP Labs	cnp		/about\nAbout Us\nAbout CNP Labs	f	2021-11-09 21:24:33+00	2021-11-09 21:28:57+00	About Us	[]	cnp-tree	About CNP Labs		cnp.dev	100	orange	CNP Labs									
\.

--
-- Data for Name: users; Type: TABLE DATA; Schema: public; Owner: root
--

COPY public.users (id, isadmin, token, github) FROM stdin;
bartr	t	Table512	
matt	t	Agency512	
cnp	t	512Table	https://github.com/cnp-labs
\.


--
-- Name: links_id_seq; Type: SEQUENCE SET; Schema: public; Owner: root
--

SELECT pg_catalog.setval('public.links_id_seq', 105, true);


--
-- Name: children children_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--

ALTER TABLE ONLY public.children
    ADD CONSTRAINT children_pkey PRIMARY KEY (parentid, childid);


--
-- Name: links links_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--

ALTER TABLE ONLY public.links
    ADD CONSTRAINT links_pkey PRIMARY KEY (id);


--
-- Name: logs logs_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--

ALTER TABLE ONLY public.logs
    ADD CONSTRAINT logs_pkey PRIMARY KEY (id);


--
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_pkey PRIMARY KEY (id);


--
-- Name: links modified_trigger; Type: TRIGGER; Schema: public; Owner: root
--

CREATE TRIGGER modified_trigger BEFORE UPDATE ON public.links FOR EACH ROW EXECUTE FUNCTION public.update_modified();
