--
-- PostgreSQL database dump
--

-- Dumped from database version 9.6.20
-- Dumped by pg_dump version 9.6.20

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: 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';


--
-- Name: post_status; Type: TYPE; Schema: public; Owner: bronibooru
--

CREATE TYPE public.post_status AS ENUM (
    'deleted',
    'flagged',
    'pending',
    'active'
);


ALTER TYPE public.post_status OWNER TO bronibooru;

SET default_tablespace = '';

SET default_with_oids = false;


--
-- Name: artist_commentaries; Type: TABLE; Schema: public; Owner: bronibooru
--

CREATE TABLE public.artist_commentaries (
    id integer NOT NULL,
    post_id integer NOT NULL,
    original_title text,
    original_description text,
    translated_title text,
    translated_description text,
    created_at timestamp without time zone,
    updated_at timestamp without time zone
);


ALTER TABLE public.artist_commentaries OWNER TO bronibooru;

--
-- Name: artist_commentaries_id_seq; Type: SEQUENCE; Schema: public; Owner: bronibooru
--

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


ALTER TABLE public.artist_commentaries_id_seq OWNER TO bronibooru;

--
-- Name: artist_commentaries_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: bronibooru
--

ALTER SEQUENCE public.artist_commentaries_id_seq OWNED BY public.artist_commentaries.id;


--
-- Name: artist_urls; Type: TABLE; Schema: public; Owner: bronibooru
--

CREATE TABLE public.artist_urls (
    id integer NOT NULL,
    artist_id integer NOT NULL,
    url text NOT NULL,
    normalized_url text NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.artist_urls OWNER TO bronibooru;

--
-- Name: artist_urls_id_seq; Type: SEQUENCE; Schema: public; Owner: bronibooru
--

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


ALTER TABLE public.artist_urls_id_seq OWNER TO bronibooru;

--
-- Name: artist_urls_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: bronibooru
--

ALTER SEQUENCE public.artist_urls_id_seq OWNED BY public.artist_urls.id;


--
-- Name: artists; Type: TABLE; Schema: public; Owner: bronibooru
--

CREATE TABLE public.artists (
    id integer NOT NULL,
    name text NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    creator_id integer,
    is_active boolean DEFAULT true NOT NULL,
    group_name character varying(255),
    is_banned boolean DEFAULT false NOT NULL,
    other_names text DEFAULT ''::text,
    other_names_index tsvector
);


ALTER TABLE public.artists OWNER TO bronibooru;

--
-- Name: artists_id_seq; Type: SEQUENCE; Schema: public; Owner: bronibooru
--

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


ALTER TABLE public.artists_id_seq OWNER TO bronibooru;

--
-- Name: artists_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: bronibooru
--

ALTER SEQUENCE public.artists_id_seq OWNED BY public.artists.id;


--
-- Name: comments; Type: TABLE; Schema: public; Owner: bronibooru
--

CREATE TABLE public.comments (
    id integer NOT NULL,
    created_at timestamp without time zone NOT NULL,
    post_id integer NOT NULL,
    creator_id integer,
    body text NOT NULL,
    body_index tsvector,
    score integer DEFAULT 0 NOT NULL,
    updated_at timestamp without time zone,
    updater_id integer,
    do_not_bump_post boolean DEFAULT false NOT NULL
);


ALTER TABLE public.comments OWNER TO bronibooru;

--
-- Name: comments_id_seq; Type: SEQUENCE; Schema: public; Owner: bronibooru
--

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


ALTER TABLE public.comments_id_seq OWNER TO bronibooru;

--
-- Name: comments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: bronibooru
--

ALTER SEQUENCE public.comments_id_seq OWNED BY public.comments.id;


--
-- Name: news_updates; Type: TABLE; Schema: public; Owner: bronibooru
--

CREATE TABLE public.news_updates (
    id integer NOT NULL,
    message text NOT NULL,
    creator_id integer NOT NULL,
    updater_id integer NOT NULL,
    created_at timestamp without time zone,
    updated_at timestamp without time zone
);


ALTER TABLE public.news_updates OWNER TO bronibooru;

--
-- Name: news_updates_id_seq; Type: SEQUENCE; Schema: public; Owner: bronibooru
--

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


ALTER TABLE public.news_updates_id_seq OWNER TO bronibooru;

--
-- Name: news_updates_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: bronibooru
--

ALTER SEQUENCE public.news_updates_id_seq OWNED BY public.news_updates.id;


--
-- Name: notes; Type: TABLE; Schema: public; Owner: bronibooru
--

CREATE TABLE public.notes (
    id integer NOT NULL,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL,
    creator_id integer,
    x integer NOT NULL,
    y integer NOT NULL,
    width integer NOT NULL,
    height integer NOT NULL,
    is_active boolean DEFAULT true NOT NULL,
    post_id integer NOT NULL,
    body text NOT NULL,
    body_index tsvector,
    version integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.notes OWNER TO bronibooru;

--
-- Name: notes_id_seq; Type: SEQUENCE; Schema: public; Owner: bronibooru
--

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


ALTER TABLE public.notes_id_seq OWNER TO bronibooru;

--
-- Name: notes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: bronibooru
--

ALTER SEQUENCE public.notes_id_seq OWNED BY public.notes.id;


--
-- Name: pools; Type: TABLE; Schema: public; Owner: bronibooru
--

CREATE TABLE public.pools (
    id integer NOT NULL,
    name text NOT NULL,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL,
    creator_id integer NOT NULL,
    post_count integer DEFAULT 0 NOT NULL,
    description text DEFAULT ''::text NOT NULL,
    is_active boolean DEFAULT true NOT NULL,
    is_deleted boolean DEFAULT false NOT NULL,
    post_ids text DEFAULT ''::text NOT NULL,
    category character varying(255) DEFAULT 'series'::character varying NOT NULL
);


ALTER TABLE public.pools OWNER TO bronibooru;

--
-- Name: pools_id_seq; Type: SEQUENCE; Schema: public; Owner: bronibooru
--

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


ALTER TABLE public.pools_id_seq OWNER TO bronibooru;

--
-- Name: pools_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: bronibooru
--

ALTER SEQUENCE public.pools_id_seq OWNED BY public.pools.id;


--
-- Name: posts; Type: TABLE; Schema: public; Owner: bronibooru
--

CREATE TABLE public.posts (
    id integer NOT NULL,
    created_at timestamp without time zone NOT NULL,
    uploader_id integer,
    score integer DEFAULT 0 NOT NULL,
    source text,
    md5 text NOT NULL,
    last_comment_bumped_at timestamp without time zone,
    rating character(1) DEFAULT 'q'::bpchar NOT NULL,
    image_width integer,
    image_height integer,
    is_warehoused boolean DEFAULT false NOT NULL,
    tag_string text DEFAULT ''::text NOT NULL,
    is_note_locked boolean DEFAULT false NOT NULL,
    fav_count integer DEFAULT 0 NOT NULL,
    file_ext text DEFAULT ''::text NOT NULL,
    last_noted_at timestamp without time zone,
    is_rating_locked boolean DEFAULT false NOT NULL,
    parent_id integer,
    has_children boolean DEFAULT false NOT NULL,
    approver_id integer,
    tag_index tsvector,
    tag_count_general integer DEFAULT 0 NOT NULL,
    tag_count_artist integer DEFAULT 0 NOT NULL,
    tag_count_character integer DEFAULT 0 NOT NULL,
    tag_count_copyright integer DEFAULT 0 NOT NULL,
    file_size integer,
    is_status_locked boolean DEFAULT false NOT NULL,
    fav_string text DEFAULT ''::text NOT NULL,
    pool_string text DEFAULT ''::text NOT NULL,
    up_score integer DEFAULT 0 NOT NULL,
    down_score integer DEFAULT 0 NOT NULL,
    is_pending boolean DEFAULT false NOT NULL,
    is_flagged boolean DEFAULT false NOT NULL,
    is_deleted boolean DEFAULT false NOT NULL,
    tag_count integer DEFAULT 0 NOT NULL,
    updated_at timestamp without time zone,
    is_banned boolean DEFAULT false NOT NULL,
    pixiv_id integer,
    last_commented_at timestamp without time zone,
    has_active_children boolean DEFAULT false
);


ALTER TABLE public.posts OWNER TO bronibooru;

--
-- Name: posts_id_seq; Type: SEQUENCE; Schema: public; Owner: bronibooru
--

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


ALTER TABLE public.posts_id_seq OWNER TO bronibooru;

--
-- Name: posts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: bronibooru
--

ALTER SEQUENCE public.posts_id_seq OWNED BY public.posts.id;


--
-- Name: tag_aliases; Type: TABLE; Schema: public; Owner: bronibooru
--

CREATE TABLE public.tag_aliases (
    id integer NOT NULL,
    antecedent_name text NOT NULL,
    reason text DEFAULT ''::text NOT NULL,
    creator_id integer,
    consequent_name character varying(255) DEFAULT ''::character varying NOT NULL,
    status character varying(255) DEFAULT 'active'::character varying NOT NULL,
    created_at timestamp without time zone DEFAULT now(),
    updated_at timestamp without time zone DEFAULT now()
);


ALTER TABLE public.tag_aliases OWNER TO bronibooru;

--
-- Name: tag_aliases_id_seq; Type: SEQUENCE; Schema: public; Owner: bronibooru
--

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


ALTER TABLE public.tag_aliases_id_seq OWNER TO bronibooru;

--
-- Name: tag_aliases_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: bronibooru
--

ALTER SEQUENCE public.tag_aliases_id_seq OWNED BY public.tag_aliases.id;


--
-- Name: tag_implications; Type: TABLE; Schema: public; Owner: bronibooru
--

CREATE TABLE public.tag_implications (
    id integer NOT NULL,
    reason text DEFAULT ''::text NOT NULL,
    creator_id integer,
    antecedent_name character varying(255) DEFAULT ''::character varying NOT NULL,
    consequent_name character varying(255) DEFAULT ''::character varying NOT NULL,
    descendant_names text DEFAULT ''::text NOT NULL,
    status character varying(255) DEFAULT 'active'::character varying NOT NULL,
    created_at timestamp without time zone DEFAULT now(),
    updated_at timestamp without time zone DEFAULT now()
);


ALTER TABLE public.tag_implications OWNER TO bronibooru;

--
-- Name: tag_implications_id_seq; Type: SEQUENCE; Schema: public; Owner: bronibooru
--

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


ALTER TABLE public.tag_implications_id_seq OWNER TO bronibooru;

--
-- Name: tag_implications_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: bronibooru
--

ALTER SEQUENCE public.tag_implications_id_seq OWNED BY public.tag_implications.id;


--
-- Name: tags; Type: TABLE; Schema: public; Owner: bronibooru
--

CREATE TABLE public.tags (
    id integer NOT NULL,
    name text NOT NULL,
    post_count integer DEFAULT 0 NOT NULL,
    related_tags text,
    related_tags_updated_at timestamp without time zone DEFAULT now(),
    category smallint DEFAULT 0 NOT NULL,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    is_locked boolean DEFAULT false NOT NULL
);


ALTER TABLE public.tags OWNER TO bronibooru;

--
-- Name: tags_id_seq; Type: SEQUENCE; Schema: public; Owner: bronibooru
--

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


ALTER TABLE public.tags_id_seq OWNER TO bronibooru;

--
-- Name: tags_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: bronibooru
--

ALTER SEQUENCE public.tags_id_seq OWNED BY public.tags.id;


--
-- Name: uploads; Type: TABLE; Schema: public; Owner: bronibooru
--

CREATE TABLE public.uploads (
    id integer NOT NULL,
    source text,
    file_path character varying(255),
    content_type character varying(255),
    rating character(1) NOT NULL,
    uploader_id integer NOT NULL,
    tag_string text NOT NULL,
    status text DEFAULT 'pending'::text NOT NULL,
    backtrace text,
    post_id integer,
    md5_confirmation character varying(255),
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    server text,
    parent_id integer
);


ALTER TABLE public.uploads OWNER TO bronibooru;

--
-- Name: uploads_id_seq; Type: SEQUENCE; Schema: public; Owner: bronibooru
--

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


ALTER TABLE public.uploads_id_seq OWNER TO bronibooru;

--
-- Name: uploads_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: bronibooru
--

ALTER SEQUENCE public.uploads_id_seq OWNED BY public.uploads.id;


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

CREATE TABLE public.users (
    id integer NOT NULL,
    name text NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone,
    post_update_count integer DEFAULT 0 NOT NULL,
    note_update_count integer DEFAULT 0 NOT NULL,
    favorite_count integer DEFAULT 0 NOT NULL,
    post_upload_count integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.users OWNER TO bronibooru;

--
-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: bronibooru
--

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


ALTER TABLE public.users_id_seq OWNER TO bronibooru;

--
-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: bronibooru
--

ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;


--
-- Name: wiki_pages; Type: TABLE; Schema: public; Owner: bronibooru
--

CREATE TABLE public.wiki_pages (
    id integer NOT NULL,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL,
    title text NOT NULL,
    body text NOT NULL,
    creator_id integer,
    is_locked boolean DEFAULT false NOT NULL,
    body_index tsvector,
    updater_id integer,
    other_names text,
    other_names_index tsvector
);


ALTER TABLE public.wiki_pages OWNER TO bronibooru;

--
-- Name: wiki_pages_id_seq; Type: SEQUENCE; Schema: public; Owner: bronibooru
--

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


ALTER TABLE public.wiki_pages_id_seq OWNER TO bronibooru;

--
-- Name: wiki_pages_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: bronibooru
--

ALTER SEQUENCE public.wiki_pages_id_seq OWNED BY public.wiki_pages.id;


--
-- Name: artist_commentaries id; Type: DEFAULT; Schema: public; Owner: bronibooru
--

ALTER TABLE ONLY public.artist_commentaries ALTER COLUMN id SET DEFAULT nextval('public.artist_commentaries_id_seq'::regclass);


--
-- Name: artist_urls id; Type: DEFAULT; Schema: public; Owner: bronibooru
--

ALTER TABLE ONLY public.artist_urls ALTER COLUMN id SET DEFAULT nextval('public.artist_urls_id_seq'::regclass);


--
-- Name: artists id; Type: DEFAULT; Schema: public; Owner: bronibooru
--

ALTER TABLE ONLY public.artists ALTER COLUMN id SET DEFAULT nextval('public.artists_id_seq'::regclass);


--
-- Name: comments id; Type: DEFAULT; Schema: public; Owner: bronibooru
--

ALTER TABLE ONLY public.comments ALTER COLUMN id SET DEFAULT nextval('public.comments_id_seq'::regclass);


--
-- Name: news_updates id; Type: DEFAULT; Schema: public; Owner: bronibooru
--

ALTER TABLE ONLY public.news_updates ALTER COLUMN id SET DEFAULT nextval('public.news_updates_id_seq'::regclass);


--
-- Name: notes id; Type: DEFAULT; Schema: public; Owner: bronibooru
--

ALTER TABLE ONLY public.notes ALTER COLUMN id SET DEFAULT nextval('public.notes_id_seq'::regclass);


--
-- Name: pools id; Type: DEFAULT; Schema: public; Owner: bronibooru
--

ALTER TABLE ONLY public.pools ALTER COLUMN id SET DEFAULT nextval('public.pools_id_seq'::regclass);


--
-- Name: posts id; Type: DEFAULT; Schema: public; Owner: bronibooru
--

ALTER TABLE ONLY public.posts ALTER COLUMN id SET DEFAULT nextval('public.posts_id_seq'::regclass);


--
-- Name: tag_aliases id; Type: DEFAULT; Schema: public; Owner: bronibooru
--

ALTER TABLE ONLY public.tag_aliases ALTER COLUMN id SET DEFAULT nextval('public.tag_aliases_id_seq'::regclass);


--
-- Name: tag_implications id; Type: DEFAULT; Schema: public; Owner: bronibooru
--

ALTER TABLE ONLY public.tag_implications ALTER COLUMN id SET DEFAULT nextval('public.tag_implications_id_seq'::regclass);


--
-- Name: tags id; Type: DEFAULT; Schema: public; Owner: bronibooru
--

ALTER TABLE ONLY public.tags ALTER COLUMN id SET DEFAULT nextval('public.tags_id_seq'::regclass);


--
-- Name: uploads id; Type: DEFAULT; Schema: public; Owner: bronibooru
--

ALTER TABLE ONLY public.uploads ALTER COLUMN id SET DEFAULT nextval('public.uploads_id_seq'::regclass);


--
-- Name: users id; Type: DEFAULT; Schema: public; Owner: bronibooru
--

ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass);


--
-- Name: wiki_pages id; Type: DEFAULT; Schema: public; Owner: bronibooru
--

ALTER TABLE ONLY public.wiki_pages ALTER COLUMN id SET DEFAULT nextval('public.wiki_pages_id_seq'::regclass);


--
-- Name: artist_commentaries artist_commentaries_pkey; Type: CONSTRAINT; Schema: public; Owner: bronibooru
--

ALTER TABLE ONLY public.artist_commentaries
    ADD CONSTRAINT artist_commentaries_pkey PRIMARY KEY (id);


--
-- Name: artist_urls artist_urls_pkey; Type: CONSTRAINT; Schema: public; Owner: bronibooru
--

ALTER TABLE ONLY public.artist_urls
    ADD CONSTRAINT artist_urls_pkey PRIMARY KEY (id);


--
-- Name: artists artists_pkey; Type: CONSTRAINT; Schema: public; Owner: bronibooru
--

ALTER TABLE ONLY public.artists
    ADD CONSTRAINT artists_pkey PRIMARY KEY (id);


--
-- Name: comments comments_pkey; Type: CONSTRAINT; Schema: public; Owner: bronibooru
--

ALTER TABLE ONLY public.comments
    ADD CONSTRAINT comments_pkey PRIMARY KEY (id);


--
-- Name: artists index_artists_on_name; Type: CONSTRAINT; Schema: public; Owner: bronibooru
--

ALTER TABLE ONLY public.artists
    ADD CONSTRAINT index_artists_on_name UNIQUE (name);


--
-- Name: news_updates news_updates_pkey; Type: CONSTRAINT; Schema: public; Owner: bronibooru
--

ALTER TABLE ONLY public.news_updates
    ADD CONSTRAINT news_updates_pkey PRIMARY KEY (id);


--
-- Name: notes notes_pkey; Type: CONSTRAINT; Schema: public; Owner: bronibooru
--

ALTER TABLE ONLY public.notes
    ADD CONSTRAINT notes_pkey PRIMARY KEY (id);


--
-- Name: pools pools_pkey; Type: CONSTRAINT; Schema: public; Owner: bronibooru
--

ALTER TABLE ONLY public.pools
    ADD CONSTRAINT pools_pkey PRIMARY KEY (id);


--
-- Name: posts posts_pkey; Type: CONSTRAINT; Schema: public; Owner: bronibooru
--

ALTER TABLE ONLY public.posts
    ADD CONSTRAINT posts_pkey PRIMARY KEY (id);


--
-- Name: tag_aliases tag_aliases_pkey; Type: CONSTRAINT; Schema: public; Owner: bronibooru
--

ALTER TABLE ONLY public.tag_aliases
    ADD CONSTRAINT tag_aliases_pkey PRIMARY KEY (id);


--
-- Name: tag_implications tag_implications_pkey; Type: CONSTRAINT; Schema: public; Owner: bronibooru
--

ALTER TABLE ONLY public.tag_implications
    ADD CONSTRAINT tag_implications_pkey PRIMARY KEY (id);


--
-- Name: tags tags_pkey; Type: CONSTRAINT; Schema: public; Owner: bronibooru
--

ALTER TABLE ONLY public.tags
    ADD CONSTRAINT tags_pkey PRIMARY KEY (id);


--
-- Name: uploads uploads_pkey; Type: CONSTRAINT; Schema: public; Owner: bronibooru
--

ALTER TABLE ONLY public.uploads
    ADD CONSTRAINT uploads_pkey PRIMARY KEY (id);


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

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


--
-- Name: wiki_pages wiki_pages_pkey; Type: CONSTRAINT; Schema: public; Owner: bronibooru
--

ALTER TABLE ONLY public.wiki_pages
    ADD CONSTRAINT wiki_pages_pkey PRIMARY KEY (id);


--
-- Name: comments_text_search_idx; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX comments_text_search_idx ON public.notes USING gin (body_index);


--
-- Name: index_artist_commentaries_on_post_id; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE UNIQUE INDEX index_artist_commentaries_on_post_id ON public.artist_commentaries USING btree (post_id);


--
-- Name: index_artist_urls_on_artist_id; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_artist_urls_on_artist_id ON public.artist_urls USING btree (artist_id);


--
-- Name: index_artist_urls_on_normalized_url; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_artist_urls_on_normalized_url ON public.artist_urls USING btree (normalized_url);


--
-- Name: index_artist_urls_on_url; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_artist_urls_on_url ON public.artist_urls USING btree (url);


--
-- Name: index_artists_on_other_names_index; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_artists_on_other_names_index ON public.artists USING gin (other_names_index);


--
-- Name: index_comments_on_creator_id_and_post_id; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_comments_on_creator_id_and_post_id ON public.comments USING btree (creator_id, post_id);


--
-- Name: index_comments_on_post_id; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_comments_on_post_id ON public.comments USING btree (post_id);


--
-- Name: index_news_updates_on_created_at; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_news_updates_on_created_at ON public.news_updates USING btree (created_at);


--
-- Name: index_notes_on_body_index; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_notes_on_body_index ON public.notes USING gin (body_index);


--
-- Name: index_notes_on_creator_id_and_post_id; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_notes_on_creator_id_and_post_id ON public.notes USING btree (creator_id, post_id);


--
-- Name: index_notes_on_post_id; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_notes_on_post_id ON public.notes USING btree (post_id);


--
-- Name: index_pools_on_creator_id; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_pools_on_creator_id ON public.pools USING btree (creator_id);


--
-- Name: index_pools_on_lower_name; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_pools_on_lower_name ON public.pools USING btree (lower(name));


--
-- Name: index_posts_on_approver_id; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_posts_on_approver_id ON public.posts USING btree (approver_id);


--
-- Name: index_posts_on_created_at; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_posts_on_created_at ON public.posts USING btree (created_at);


--
-- Name: index_posts_on_file_size; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_posts_on_file_size ON public.posts USING btree (file_size);


--
-- Name: index_posts_on_image_height; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_posts_on_image_height ON public.posts USING btree (image_height);


--
-- Name: index_posts_on_image_width; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_posts_on_image_width ON public.posts USING btree (image_width);


--
-- Name: index_posts_on_last_comment_bumped_at; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_posts_on_last_comment_bumped_at ON public.posts USING btree (last_comment_bumped_at) WHERE (last_comment_bumped_at IS NOT NULL);


--
-- Name: index_posts_on_last_noted_at; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_posts_on_last_noted_at ON public.posts USING btree (last_noted_at) WHERE (last_noted_at IS NOT NULL);


--
-- Name: index_posts_on_md5; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE UNIQUE INDEX index_posts_on_md5 ON public.posts USING btree (md5);


--
-- Name: index_posts_on_mpixels; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_posts_on_mpixels ON public.posts USING btree (((((image_width * image_height))::numeric / 1000000.0)));


--
-- Name: index_posts_on_parent_id; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_posts_on_parent_id ON public.posts USING btree (parent_id) WHERE (parent_id IS NOT NULL);


--
-- Name: index_posts_on_pixiv_id; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_posts_on_pixiv_id ON public.posts USING btree (pixiv_id) WHERE (pixiv_id IS NOT NULL);


--
-- Name: index_posts_on_source; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_posts_on_source ON public.posts USING btree (lower(source));


--
-- Name: index_posts_on_source_pattern; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_posts_on_source_pattern ON public.posts USING btree (public.sourcepattern(lower(source)) text_pattern_ops);


--
-- Name: index_posts_on_tag_index; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_posts_on_tag_index ON public.posts USING gin (tag_index);


--
-- Name: index_posts_on_uploader_id; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_posts_on_uploader_id ON public.posts USING btree (uploader_id) WHERE (uploader_id IS NOT NULL);


--
-- Name: index_tag_aliases_on_antecedent_name; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE UNIQUE INDEX index_tag_aliases_on_antecedent_name ON public.tag_aliases USING btree (antecedent_name);


--
-- Name: index_tag_aliases_on_consequent_name; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_tag_aliases_on_consequent_name ON public.tag_aliases USING btree (consequent_name);


--
-- Name: index_tags_on_name; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE UNIQUE INDEX index_tags_on_name ON public.tags USING btree (name);


--
-- Name: index_tags_on_post_count; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_tags_on_post_count ON public.tags USING btree (post_count);


--
-- Name: index_uploads_on_uploader_id; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_uploads_on_uploader_id ON public.uploads USING btree (uploader_id);


--
-- Name: index_users_on_name; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_users_on_name ON public.users USING btree (lower(name));


--
-- Name: index_wiki_pages_on_body_index; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_wiki_pages_on_body_index ON public.wiki_pages USING gin (body_index);


--
-- Name: index_wiki_pages_on_other_names_index; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_wiki_pages_on_other_names_index ON public.wiki_pages USING gin (other_names_index);


--
-- Name: index_wiki_pages_on_title; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE UNIQUE INDEX index_wiki_pages_on_title ON public.wiki_pages USING btree (title);


--
-- Name: index_wiki_pages_on_updated_at; Type: INDEX; Schema: public; Owner: bronibooru
--

CREATE INDEX index_wiki_pages_on_updated_at ON public.wiki_pages USING btree (updated_at);


--
-- Name: artists trigger_artists_on_update; Type: TRIGGER; Schema: public; Owner: bronibooru
--

CREATE TRIGGER trigger_artists_on_update BEFORE INSERT OR UPDATE ON public.artists FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('other_names_index', 'public.danbooru', 'other_names');


--
-- Name: comments trigger_comments_on_update; Type: TRIGGER; Schema: public; Owner: bronibooru
--

CREATE TRIGGER trigger_comments_on_update BEFORE INSERT OR UPDATE ON public.comments FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('body_index', 'pg_catalog.english', 'body');


--
-- Name: notes trigger_notes_on_update; Type: TRIGGER; Schema: public; Owner: bronibooru
--

CREATE TRIGGER trigger_notes_on_update BEFORE INSERT OR UPDATE ON public.notes FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('body_index', 'pg_catalog.english', 'body');


--
-- Name: posts trigger_posts_on_tag_index_update; Type: TRIGGER; Schema: public; Owner: bronibooru
--

CREATE TRIGGER trigger_posts_on_tag_index_update BEFORE INSERT OR UPDATE ON public.posts FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('tag_index', 'public.danbooru', 'tag_string', 'fav_string', 'pool_string');


--
-- Name: wiki_pages trigger_wiki_pages_on_update; Type: TRIGGER; Schema: public; Owner: bronibooru
--

CREATE TRIGGER trigger_wiki_pages_on_update BEFORE INSERT OR UPDATE ON public.wiki_pages FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('body_index', 'public.danbooru', 'body', 'title');


--
-- Name: wiki_pages trigger_wiki_pages_on_update_for_other_names; Type: TRIGGER; Schema: public; Owner: bronibooru
--

CREATE TRIGGER trigger_wiki_pages_on_update_for_other_names BEFORE INSERT OR UPDATE ON public.wiki_pages FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('other_names_index', 'public.danbooru', 'other_names');


--
-- PostgreSQL database dump complete
--

