--
-- PostgreSQL database dump
--

\restrict sfKzavw6BT7S48XgpklDXrRN4BzPBCBJB1apavBd4jjyastMTwALfb7ctd9PV5I

-- Dumped from database version 18.6 (Debian 18.6-1.pgdg13+2)
-- Dumped by pg_dump version 18.6

-- Started on 2026-11-22 11:57:31 UTC

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_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;

--
-- TOC entry 4 (class 2615 OID 2200)
-- Name: public; Type: SCHEMA; Schema: -; Owner: pg_database_owner
--

CREATE SCHEMA public;


ALTER SCHEMA public OWNER TO pg_database_owner;

--
-- TOC entry 3589 (class 0 OID 0)
-- Dependencies: 4
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: pg_database_owner
--

COMMENT ON SCHEMA public IS 'standard public schema';


SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- TOC entry 220 (class 1259 OID 52996)
-- Name: account; Type: TABLE; Schema: public; Owner: kver
--

CREATE TABLE public.account (
    id bigint NOT NULL,
    uid bigint NOT NULL,
    legacy_name text,
    password bytea NOT NULL,
    created_at bigint NOT NULL,
    last_login bigint,
    avatar text DEFAULT ''::text NOT NULL,
    bio text DEFAULT ''::text NOT NULL,
    header text DEFAULT ''::text NOT NULL,
    handle text NOT NULL,
    display_name text DEFAULT ''::text NOT NULL
);


ALTER TABLE public.account OWNER TO kver;

--
-- TOC entry 219 (class 1259 OID 52995)
-- Name: account_id_seq; Type: SEQUENCE; Schema: public; Owner: kver
--

ALTER TABLE public.account ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.account_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- TOC entry 234 (class 1259 OID 77480)
-- Name: account_key; Type: TABLE; Schema: public; Owner: kver
--

CREATE TABLE public.account_key (
    id bigint NOT NULL,
    uid bigint NOT NULL,
    fingerprint bytea NOT NULL,
    public_key bytea NOT NULL,
    secret_key bytea NOT NULL,
    created_at bigint NOT NULL,
    replaced_at bigint DEFAULT 0 NOT NULL,
    lost_at bigint DEFAULT 0 NOT NULL
);


ALTER TABLE public.account_key OWNER TO kver;

--
-- TOC entry 233 (class 1259 OID 77479)
-- Name: account_key_id_seq; Type: SEQUENCE; Schema: public; Owner: kver
--

ALTER TABLE public.account_key ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.account_key_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- TOC entry 224 (class 1259 OID 53032)
-- Name: entry; Type: TABLE; Schema: public; Owner: kver
--

CREATE TABLE public.entry (
    id bigint NOT NULL,
    pid bigint NOT NULL,
    uid bigint NOT NULL,
    created_at bigint NOT NULL,
    content text DEFAULT ''::text NOT NULL,
    filepath text DEFAULT ''::text NOT NULL,
    reply_to bigint DEFAULT 0 NOT NULL,
    reply_count bigint DEFAULT 0 NOT NULL,
    last_activity bigint DEFAULT 0 NOT NULL,
    deleted bigint DEFAULT 0 NOT NULL,
    bump_count bigint DEFAULT 0 NOT NULL,
    last_bump bigint DEFAULT 0 NOT NULL,
    link_url text DEFAULT ''::text NOT NULL,
    image_warning text DEFAULT ''::text NOT NULL,
    image_cover text DEFAULT ''::text NOT NULL
);


ALTER TABLE public.entry OWNER TO kver;

--
-- TOC entry 223 (class 1259 OID 53031)
-- Name: entry_id_seq; Type: SEQUENCE; Schema: public; Owner: kver
--

ALTER TABLE public.entry ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.entry_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- TOC entry 240 (class 1259 OID 123529)
-- Name: entry_tag; Type: TABLE; Schema: public; Owner: kver
--

CREATE TABLE public.entry_tag (
    pid bigint NOT NULL,
    tag text NOT NULL
);


ALTER TABLE public.entry_tag OWNER TO kver;

--
-- TOC entry 227 (class 1259 OID 53075)
-- Name: impression; Type: TABLE; Schema: public; Owner: kver
--

CREATE TABLE public.impression (
    day text NOT NULL,
    anon_ip text NOT NULL,
    path text DEFAULT ''::text NOT NULL,
    asn text DEFAULT ''::text NOT NULL,
    hits bigint DEFAULT 0 NOT NULL
);


ALTER TABLE public.impression OWNER TO kver;

--
-- TOC entry 232 (class 1259 OID 67157)
-- Name: link_preview; Type: TABLE; Schema: public; Owner: kver
--

CREATE TABLE public.link_preview (
    url text NOT NULL,
    kind text DEFAULT ''::text NOT NULL,
    title text DEFAULT ''::text NOT NULL,
    site text DEFAULT ''::text NOT NULL,
    thumb text DEFAULT ''::text NOT NULL,
    status text DEFAULT 'pending'::text NOT NULL,
    fetched_at bigint DEFAULT 0 NOT NULL,
    attempts integer DEFAULT 0 NOT NULL,
    retry_at bigint DEFAULT 0 NOT NULL
);


ALTER TABLE public.link_preview OWNER TO kver;

--
-- TOC entry 239 (class 1259 OID 123498)
-- Name: mention; Type: TABLE; Schema: public; Owner: kver
--

CREATE TABLE public.mention (
    pid bigint NOT NULL,
    handle text NOT NULL,
    uid bigint NOT NULL
);


ALTER TABLE public.mention OWNER TO kver;

--
-- TOC entry 236 (class 1259 OID 77502)
-- Name: message; Type: TABLE; Schema: public; Owner: kver
--

CREATE TABLE public.message (
    id bigint NOT NULL,
    sender bigint NOT NULL,
    recipient bigint NOT NULL,
    body bytea NOT NULL,
    created_at bigint NOT NULL,
    read_at bigint DEFAULT 0 NOT NULL
);


ALTER TABLE public.message OWNER TO kver;

--
-- TOC entry 235 (class 1259 OID 77501)
-- Name: message_id_seq; Type: SEQUENCE; Schema: public; Owner: kver
--

ALTER TABLE public.message ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.message_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- TOC entry 238 (class 1259 OID 123452)
-- Name: notification; Type: TABLE; Schema: public; Owner: kver
--

CREATE TABLE public.notification (
    id bigint NOT NULL,
    uid bigint NOT NULL,
    kind text NOT NULL,
    actor bigint DEFAULT 0 NOT NULL,
    excerpt text DEFAULT ''::text NOT NULL,
    link text NOT NULL,
    pid bigint DEFAULT 0 NOT NULL,
    created_at bigint NOT NULL,
    seen_at bigint DEFAULT 0 NOT NULL
);


ALTER TABLE public.notification OWNER TO kver;

--
-- TOC entry 237 (class 1259 OID 123451)
-- Name: notification_id_seq; Type: SEQUENCE; Schema: public; Owner: kver
--

ALTER TABLE public.notification ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.notification_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- TOC entry 231 (class 1259 OID 60666)
-- Name: password_reset; Type: TABLE; Schema: public; Owner: kver
--

CREATE TABLE public.password_reset (
    id bigint NOT NULL,
    uid bigint NOT NULL,
    token_hash text NOT NULL,
    created_at bigint NOT NULL,
    expires bigint NOT NULL
);


ALTER TABLE public.password_reset OWNER TO kver;

--
-- TOC entry 230 (class 1259 OID 60665)
-- Name: password_reset_id_seq; Type: SEQUENCE; Schema: public; Owner: kver
--

ALTER TABLE public.password_reset ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.password_reset_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- TOC entry 229 (class 1259 OID 53091)
-- Name: report; Type: TABLE; Schema: public; Owner: kver
--

CREATE TABLE public.report (
    id bigint NOT NULL,
    pid bigint NOT NULL,
    uid bigint DEFAULT 0 NOT NULL,
    reason text DEFAULT ''::text NOT NULL,
    created_at bigint NOT NULL,
    handled bigint DEFAULT 0 NOT NULL
);


ALTER TABLE public.report OWNER TO kver;

--
-- TOC entry 228 (class 1259 OID 53090)
-- Name: report_id_seq; Type: SEQUENCE; Schema: public; Owner: kver
--

ALTER TABLE public.report ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.report_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- TOC entry 222 (class 1259 OID 53015)
-- Name: session; Type: TABLE; Schema: public; Owner: kver
--

CREATE TABLE public.session (
    id bigint NOT NULL,
    uid bigint NOT NULL,
    value text NOT NULL,
    created_at bigint NOT NULL,
    expires bigint NOT NULL,
    description text DEFAULT ''::text NOT NULL
);


ALTER TABLE public.session OWNER TO kver;

--
-- TOC entry 221 (class 1259 OID 53014)
-- Name: session_id_seq; Type: SEQUENCE; Schema: public; Owner: kver
--

ALTER TABLE public.session ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.session_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- TOC entry 226 (class 1259 OID 53062)
-- Name: vote; Type: TABLE; Schema: public; Owner: kver
--

CREATE TABLE public.vote (
    id bigint NOT NULL,
    uid bigint NOT NULL,
    pid bigint NOT NULL,
    mode text NOT NULL
);


ALTER TABLE public.vote OWNER TO kver;

--
-- TOC entry 225 (class 1259 OID 53061)
-- Name: vote_id_seq; Type: SEQUENCE; Schema: public; Owner: kver
--

ALTER TABLE public.vote ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.vote_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- TOC entry 3380 (class 2606 OID 114443)
-- Name: account account_handle_key; Type: CONSTRAINT; Schema: public; Owner: kver
--

ALTER TABLE ONLY public.account
    ADD CONSTRAINT account_handle_key UNIQUE (handle);


--
-- TOC entry 3417 (class 2606 OID 77498)
-- Name: account_key account_key_fingerprint_key; Type: CONSTRAINT; Schema: public; Owner: kver
--

ALTER TABLE ONLY public.account_key
    ADD CONSTRAINT account_key_fingerprint_key UNIQUE (fingerprint);


--
-- TOC entry 3419 (class 2606 OID 77496)
-- Name: account_key account_key_pkey; Type: CONSTRAINT; Schema: public; Owner: kver
--

ALTER TABLE ONLY public.account_key
    ADD CONSTRAINT account_key_pkey PRIMARY KEY (id);


--
-- TOC entry 3382 (class 2606 OID 53009)
-- Name: account account_pkey; Type: CONSTRAINT; Schema: public; Owner: kver
--

ALTER TABLE ONLY public.account
    ADD CONSTRAINT account_pkey PRIMARY KEY (id);


--
-- TOC entry 3384 (class 2606 OID 53011)
-- Name: account account_uid_key; Type: CONSTRAINT; Schema: public; Owner: kver
--

ALTER TABLE ONLY public.account
    ADD CONSTRAINT account_uid_key UNIQUE (uid);


--
-- TOC entry 3386 (class 2606 OID 53013)
-- Name: account account_username_key; Type: CONSTRAINT; Schema: public; Owner: kver
--

ALTER TABLE ONLY public.account
    ADD CONSTRAINT account_username_key UNIQUE (legacy_name);


--
-- TOC entry 3393 (class 2606 OID 53060)
-- Name: entry entry_pid_key; Type: CONSTRAINT; Schema: public; Owner: kver
--

ALTER TABLE ONLY public.entry
    ADD CONSTRAINT entry_pid_key UNIQUE (pid);


--
-- TOC entry 3395 (class 2606 OID 53058)
-- Name: entry entry_pkey; Type: CONSTRAINT; Schema: public; Owner: kver
--

ALTER TABLE ONLY public.entry
    ADD CONSTRAINT entry_pkey PRIMARY KEY (id);


--
-- TOC entry 3435 (class 2606 OID 123537)
-- Name: entry_tag entry_tag_pkey; Type: CONSTRAINT; Schema: public; Owner: kver
--

ALTER TABLE ONLY public.entry_tag
    ADD CONSTRAINT entry_tag_pkey PRIMARY KEY (pid, tag);


--
-- TOC entry 3406 (class 2606 OID 53089)
-- Name: impression impression_pkey; Type: CONSTRAINT; Schema: public; Owner: kver
--

ALTER TABLE ONLY public.impression
    ADD CONSTRAINT impression_pkey PRIMARY KEY (day, anon_ip, path);


--
-- TOC entry 3415 (class 2606 OID 67176)
-- Name: link_preview link_preview_pkey; Type: CONSTRAINT; Schema: public; Owner: kver
--

ALTER TABLE ONLY public.link_preview
    ADD CONSTRAINT link_preview_pkey PRIMARY KEY (url);


--
-- TOC entry 3433 (class 2606 OID 123507)
-- Name: mention mention_pkey; Type: CONSTRAINT; Schema: public; Owner: kver
--

ALTER TABLE ONLY public.mention
    ADD CONSTRAINT mention_pkey PRIMARY KEY (pid, handle);


--
-- TOC entry 3426 (class 2606 OID 77515)
-- Name: message message_pkey; Type: CONSTRAINT; Schema: public; Owner: kver
--

ALTER TABLE ONLY public.message
    ADD CONSTRAINT message_pkey PRIMARY KEY (id);


--
-- TOC entry 3430 (class 2606 OID 123471)
-- Name: notification notification_pkey; Type: CONSTRAINT; Schema: public; Owner: kver
--

ALTER TABLE ONLY public.notification
    ADD CONSTRAINT notification_pkey PRIMARY KEY (id);


--
-- TOC entry 3411 (class 2606 OID 60677)
-- Name: password_reset password_reset_pkey; Type: CONSTRAINT; Schema: public; Owner: kver
--

ALTER TABLE ONLY public.password_reset
    ADD CONSTRAINT password_reset_pkey PRIMARY KEY (id);


--
-- TOC entry 3413 (class 2606 OID 60679)
-- Name: password_reset password_reset_token_hash_key; Type: CONSTRAINT; Schema: public; Owner: kver
--

ALTER TABLE ONLY public.password_reset
    ADD CONSTRAINT password_reset_token_hash_key UNIQUE (token_hash);


--
-- TOC entry 3409 (class 2606 OID 53106)
-- Name: report report_pkey; Type: CONSTRAINT; Schema: public; Owner: kver
--

ALTER TABLE ONLY public.report
    ADD CONSTRAINT report_pkey PRIMARY KEY (id);


--
-- TOC entry 3389 (class 2606 OID 53028)
-- Name: session session_pkey; Type: CONSTRAINT; Schema: public; Owner: kver
--

ALTER TABLE ONLY public.session
    ADD CONSTRAINT session_pkey PRIMARY KEY (id);


--
-- TOC entry 3391 (class 2606 OID 53030)
-- Name: session session_value_key; Type: CONSTRAINT; Schema: public; Owner: kver
--

ALTER TABLE ONLY public.session
    ADD CONSTRAINT session_value_key UNIQUE (value);


--
-- TOC entry 3402 (class 2606 OID 53072)
-- Name: vote vote_pkey; Type: CONSTRAINT; Schema: public; Owner: kver
--

ALTER TABLE ONLY public.vote
    ADD CONSTRAINT vote_pkey PRIMARY KEY (id);


--
-- TOC entry 3404 (class 2606 OID 53074)
-- Name: vote vote_uid_pid_key; Type: CONSTRAINT; Schema: public; Owner: kver
--

ALTER TABLE ONLY public.vote
    ADD CONSTRAINT vote_uid_pid_key UNIQUE (uid, pid);


--
-- TOC entry 3420 (class 1259 OID 77499)
-- Name: idx_account_key_current; Type: INDEX; Schema: public; Owner: kver
--

CREATE UNIQUE INDEX idx_account_key_current ON public.account_key USING btree (uid) WHERE (replaced_at = 0);


--
-- TOC entry 3421 (class 1259 OID 77500)
-- Name: idx_account_key_uid; Type: INDEX; Schema: public; Owner: kver
--

CREATE INDEX idx_account_key_uid ON public.account_key USING btree (uid);


--
-- TOC entry 3396 (class 1259 OID 53107)
-- Name: idx_entry_last_activity; Type: INDEX; Schema: public; Owner: kver
--

CREATE INDEX idx_entry_last_activity ON public.entry USING btree (last_activity);


--
-- TOC entry 3397 (class 1259 OID 53108)
-- Name: idx_entry_reply_to; Type: INDEX; Schema: public; Owner: kver
--

CREATE INDEX idx_entry_reply_to ON public.entry USING btree (reply_to);


--
-- TOC entry 3398 (class 1259 OID 75703)
-- Name: idx_entry_siblings; Type: INDEX; Schema: public; Owner: kver
--

CREATE INDEX idx_entry_siblings ON public.entry USING btree (reply_to, last_activity, pid);


--
-- TOC entry 3436 (class 1259 OID 123538)
-- Name: idx_entry_tag_tag; Type: INDEX; Schema: public; Owner: kver
--

CREATE INDEX idx_entry_tag_tag ON public.entry_tag USING btree (tag text_pattern_ops);


--
-- TOC entry 3399 (class 1259 OID 53109)
-- Name: idx_entry_uid; Type: INDEX; Schema: public; Owner: kver
--

CREATE INDEX idx_entry_uid ON public.entry USING btree (uid);


--
-- TOC entry 3431 (class 1259 OID 123508)
-- Name: idx_mention_uid; Type: INDEX; Schema: public; Owner: kver
--

CREATE INDEX idx_mention_uid ON public.mention USING btree (uid);


--
-- TOC entry 3422 (class 1259 OID 77518)
-- Name: idx_message_created; Type: INDEX; Schema: public; Owner: kver
--

CREATE INDEX idx_message_created ON public.message USING btree (created_at);


--
-- TOC entry 3423 (class 1259 OID 77516)
-- Name: idx_message_pair; Type: INDEX; Schema: public; Owner: kver
--

CREATE INDEX idx_message_pair ON public.message USING btree (sender, recipient, id);


--
-- TOC entry 3424 (class 1259 OID 77517)
-- Name: idx_message_recipient; Type: INDEX; Schema: public; Owner: kver
--

CREATE INDEX idx_message_recipient ON public.message USING btree (recipient, id);


--
-- TOC entry 3427 (class 1259 OID 123473)
-- Name: idx_notification_pid; Type: INDEX; Schema: public; Owner: kver
--

CREATE INDEX idx_notification_pid ON public.notification USING btree (pid);


--
-- TOC entry 3428 (class 1259 OID 123472)
-- Name: idx_notification_uid; Type: INDEX; Schema: public; Owner: kver
--

CREATE INDEX idx_notification_uid ON public.notification USING btree (uid, id);


--
-- TOC entry 3407 (class 1259 OID 53112)
-- Name: idx_report_open; Type: INDEX; Schema: public; Owner: kver
--

CREATE INDEX idx_report_open ON public.report USING btree (handled, created_at);


--
-- TOC entry 3387 (class 1259 OID 53111)
-- Name: idx_session_uid; Type: INDEX; Schema: public; Owner: kver
--

CREATE INDEX idx_session_uid ON public.session USING btree (uid);


--
-- TOC entry 3400 (class 1259 OID 53110)
-- Name: idx_vote_pid; Type: INDEX; Schema: public; Owner: kver
--

CREATE INDEX idx_vote_pid ON public.vote USING btree (pid);


-- Completed on 2026-11-22 11:57:31 UTC

--
-- PostgreSQL database dump complete
--

\unrestrict sfKzavw6BT7S48XgpklDXrRN4BzPBCBJB1apavBd4jjyastMTwALfb7ctd9PV5I

