From cb1bb4e43b400491f9b60abc6ca0c64df6da1267 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 20 May 2022 22:00:01 +0000 Subject: [PATCH 1/6] sneed --- schema.sql | 1852 ---------------------------------------------------- 1 file changed, 1852 deletions(-) diff --git a/schema.sql b/schema.sql index b6cfe89eb..e69de29bb 100644 --- a/schema.sql +++ b/schema.sql @@ -1,1852 +0,0 @@ --- --- PostgreSQL database dump --- - --- Dumped from database version 13.6 --- Dumped by pg_dump version 14.2 (Ubuntu 14.2-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: fuzzystrmatch; Type: EXTENSION; Schema: -; Owner: - --- - -CREATE EXTENSION IF NOT EXISTS fuzzystrmatch WITH SCHEMA public; - - --- --- Name: EXTENSION fuzzystrmatch; Type: COMMENT; Schema: -; Owner: - --- - -COMMENT ON EXTENSION fuzzystrmatch IS 'determine similarities and distance between strings'; - - --- --- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner: - --- - -CREATE EXTENSION IF NOT EXISTS pg_stat_statements WITH SCHEMA public; - - --- --- Name: EXTENSION pg_stat_statements; Type: COMMENT; Schema: -; Owner: - --- - -COMMENT ON EXTENSION pg_stat_statements IS 'track planning and execution statistics of all SQL statements executed'; - - --- --- Name: pg_trgm; Type: EXTENSION; Schema: -; Owner: - --- - -CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public; - - --- --- Name: EXTENSION pg_trgm; Type: COMMENT; Schema: -; Owner: - --- - -COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching based on trigrams'; - - -SET default_tablespace = ''; - -SET default_table_access_method = heap; - --- --- Name: submissions; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.submissions ( - id integer NOT NULL, - author_id integer NOT NULL, - created_utc integer NOT NULL, - is_banned boolean DEFAULT false NOT NULL, - over_18 boolean DEFAULT false NOT NULL, - distinguish_level integer DEFAULT 0 NOT NULL, - deleted_utc integer DEFAULT 0 NOT NULL, - is_approved integer, - edited_utc integer DEFAULT 0 NOT NULL, - is_pinned boolean DEFAULT false NOT NULL, - upvotes integer DEFAULT 1 NOT NULL, - downvotes integer DEFAULT 0 NOT NULL, - app_id integer, - thumburl character varying(200), - private boolean DEFAULT false NOT NULL, - views integer DEFAULT 0 NOT NULL, - is_bot boolean DEFAULT false NOT NULL, - bannedfor boolean, - comment_count integer DEFAULT 0 NOT NULL, - club boolean DEFAULT false NOT NULL, - stickied character varying(40), - title character varying(500) NOT NULL, - url character varying(2083), - body character varying(20000), - body_html character varying(40000), - embed_url character varying(1500), - ban_reason character varying(25), - title_html character varying(1500) NOT NULL, - realupvotes integer, - flair character varying(350), - stickied_utc integer, - ghost boolean DEFAULT false NOT NULL, - sub character varying(20), - new boolean -); - - --- --- Name: bump_utc(public.submissions); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION public.bump_utc(public.submissions) RETURNS integer - LANGUAGE sql IMMUTABLE STRICT - AS $_$ - SELECT CREATED_UTC - FROM comments - WHERE parent_submission = $1.id - ORDER BY created_utc desc - LIMIT 1 - $_$; - - --- --- Name: alts; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.alts ( - user1 integer NOT NULL, - user2 integer NOT NULL, - is_manual boolean DEFAULT false NOT NULL, - CONSTRAINT alts_cant_be_equal CHECK ((user1 <> user2)) -); - - --- --- Name: award_relationships; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.award_relationships ( - id integer NOT NULL, - user_id integer NOT NULL, - submission_id integer, - comment_id integer, - kind character varying(20) NOT NULL -); - - --- --- Name: award_relationships_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.award_relationships_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: award_relationships_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.award_relationships_id_seq OWNED BY public.award_relationships.id; - - --- --- Name: badge_defs; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.badge_defs ( - id integer NOT NULL, - name character varying(50) NOT NULL, - description character varying(200) -); - - --- --- Name: badge_defs_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.badge_defs_id_seq - AS integer - START WITH 106 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: badge_defs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.badge_defs_id_seq OWNED BY public.badge_defs.id; - - --- --- Name: badges; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.badges ( - badge_id integer NOT NULL, - user_id integer NOT NULL, - description character varying(256), - url character varying(256) -); - - --- --- Name: banneddomains; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.banneddomains ( - domain character varying(100) NOT NULL, - reason character varying(100) NOT NULL -); - - --- --- Name: client_auths; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.client_auths ( - user_id integer NOT NULL, - oauth_client integer NOT NULL, - access_token character(128) NOT NULL -); - - --- --- Name: comment_save_relationship; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.comment_save_relationship ( - user_id integer NOT NULL, - comment_id integer NOT NULL -); - - --- --- Name: commentflags; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.commentflags ( - user_id integer NOT NULL, - comment_id integer NOT NULL, - reason character varying(350), - created_utc integer NOT NULL -); - - --- --- Name: comments; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.comments ( - id integer NOT NULL, - author_id integer NOT NULL, - created_utc integer NOT NULL, - parent_submission integer, - is_banned boolean DEFAULT false NOT NULL, - distinguish_level integer DEFAULT 0 NOT NULL, - edited_utc integer DEFAULT 0 NOT NULL, - deleted_utc integer DEFAULT 0 NOT NULL, - is_approved integer, - level integer DEFAULT 0 NOT NULL, - parent_comment_id integer, - over_18 boolean DEFAULT false NOT NULL, - upvotes integer DEFAULT 1 NOT NULL, - downvotes integer DEFAULT 0 NOT NULL, - is_bot boolean DEFAULT false NOT NULL, - app_id integer, - sentto integer, - bannedfor boolean, - is_pinned character varying(40), - body character varying(10000), - body_html character varying(40000), - ban_reason character varying(25), - realupvotes integer DEFAULT 1 NOT NULL, - top_comment_id integer, - is_pinned_utc integer, - ghost boolean DEFAULT false NOT NULL, - slots_result character varying(32), - blackjack_result character varying(860), - treasure_amount character varying(10), - wordle_result character varying(115) -); - - --- --- Name: comments_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.comments_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: comments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.comments_id_seq OWNED BY public.comments.id; - - --- --- Name: commentvotes; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.commentvotes ( - comment_id integer NOT NULL, - vote_type integer NOT NULL, - user_id integer NOT NULL, - app_id integer, - "real" boolean DEFAULT true NOT NULL, - created_utc integer NOT NULL -); - - --- --- Name: exiles; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.exiles ( - user_id integer NOT NULL, - sub character varying(20) NOT NULL, - exiler_id integer NOT NULL -); - - --- --- Name: flags; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.flags ( - user_id integer NOT NULL, - post_id integer NOT NULL, - reason character varying(350), - created_utc integer NOT NULL -); - - --- --- Name: follows; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.follows ( - user_id integer NOT NULL, - target_id integer NOT NULL, - created_utc integer NOT NULL -); - - --- --- Name: marseys; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.marseys ( - name character varying(30) NOT NULL, - author_id integer NOT NULL, - tags character varying(200) NOT NULL, - count integer DEFAULT 0 NOT NULL -); - - --- --- Name: modactions; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.modactions ( - id integer NOT NULL, - user_id integer, - target_user_id integer, - target_submission_id integer, - target_comment_id integer, - created_utc integer NOT NULL, - kind character varying(32) DEFAULT NULL::character varying, - _note character varying(256) DEFAULT NULL::character varying -); - - --- --- Name: modactions_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.modactions_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: modactions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.modactions_id_seq OWNED BY public.modactions.id; - - --- --- Name: mods; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.mods ( - user_id integer NOT NULL, - sub character varying(20) NOT NULL, - created_utc integer NOT NULL -); - - --- --- Name: notifications; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.notifications ( - user_id integer NOT NULL, - comment_id integer NOT NULL, - read boolean NOT NULL, - created_utc integer NOT NULL -); - - --- --- Name: oauth_apps; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.oauth_apps ( - id integer NOT NULL, - client_id character(64), - app_name character varying(50) NOT NULL, - redirect_uri character varying(4096) NOT NULL, - author_id integer NOT NULL, - description character varying(256) NOT NULL -); - - --- --- Name: oauth_apps_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.oauth_apps_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: oauth_apps_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.oauth_apps_id_seq OWNED BY public.oauth_apps.id; - - --- --- Name: save_relationship; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.save_relationship ( - submission_id integer NOT NULL, - user_id integer NOT NULL -); - - --- --- Name: sub_blocks; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.sub_blocks ( - user_id integer NOT NULL, - sub character varying(20) NOT NULL -); - - --- --- Name: submissions_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.submissions_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: submissions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.submissions_id_seq OWNED BY public.submissions.id; - - --- --- Name: subs; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.subs ( - name character varying(20) NOT NULL, - sidebar character varying(500), - sidebar_html character varying(1000), - sidebarurl character varying(60), - bannerurl character varying(60), - css character varying(4000) -); - - --- --- Name: subscriptions; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.subscriptions ( - user_id integer NOT NULL, - submission_id integer NOT NULL -); - - --- --- Name: userblocks; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.userblocks ( - user_id integer NOT NULL, - target_id integer NOT NULL -); - - --- --- Name: users; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.users ( - id integer NOT NULL, - username character varying(255) NOT NULL, - email character varying(255), - passhash character varying(255) NOT NULL, - created_utc integer NOT NULL, - admin_level integer DEFAULT 0 NOT NULL, - over_18 boolean DEFAULT false NOT NULL, - is_activated boolean DEFAULT false NOT NULL, - bio character varying(1500), - bio_html character varying(10000), - referred_by integer, - is_banned integer DEFAULT 0 NOT NULL, - ban_reason character varying(256), - login_nonce integer DEFAULT 0 NOT NULL, - reserved character varying(256), - mfa_secret character varying(32), - is_private boolean DEFAULT false NOT NULL, - unban_utc integer DEFAULT 0 NOT NULL, - is_nofollow boolean DEFAULT false NOT NULL, - custom_filter_list character varying(1000) DEFAULT ''::character varying, - discord_id character varying(64), - stored_subscriber_count integer DEFAULT 0 NOT NULL, - ban_evade integer DEFAULT 0 NOT NULL, - original_username character varying(255), - customtitle character varying(1000), - defaultsorting character varying(15) DEFAULT 'hot'::character varying NOT NULL, - defaulttime character varying(5) NOT NULL, - namecolor character varying(6) NOT NULL, - titlecolor character varying(6) NOT NULL, - profileurl character varying(65), - bannerurl character varying(65), - hidevotedon boolean DEFAULT false NOT NULL, - newtab boolean DEFAULT false NOT NULL, - flairchanged integer, - defaultsortingcomments character varying(15) DEFAULT 'top'::character varying NOT NULL, - theme character varying(15) NOT NULL, - song character varying(50), - slurreplacer boolean DEFAULT true NOT NULL, - shadowbanned character varying(25), - newtabexternal boolean DEFAULT true NOT NULL, - customtitleplain character varying(100), - themecolor character varying(6) NOT NULL, - changelogsub boolean DEFAULT false NOT NULL, - css character varying(4000), - profilecss character varying(4000), - coins integer DEFAULT 0 NOT NULL, - agendaposter integer DEFAULT 0 NOT NULL, - post_count integer DEFAULT 0 NOT NULL, - comment_count integer DEFAULT 0 NOT NULL, - highres character varying(60), - patron integer DEFAULT 0 NOT NULL, - controversial boolean DEFAULT false NOT NULL, - background character varying(20), - verified character varying(100), - cardview boolean NOT NULL, - received_award_count integer DEFAULT 0 NOT NULL, - highlightcomments boolean DEFAULT true NOT NULL, - nitter boolean, - truecoins integer DEFAULT 0 NOT NULL, - club_allowed boolean, - frontsize integer DEFAULT 25 NOT NULL, - coins_spent integer DEFAULT 0 NOT NULL, - procoins integer DEFAULT 0 NOT NULL, - mute boolean, - unmutable boolean, - verifiedcolor character varying(6), - marseyawarded integer, - sig character varying(200), - sig_html character varying(1000), - friends character varying(500), - friends_html character varying(2000), - sigs_disabled boolean, - enemies character varying(500), - enemies_html character varying(2000), - fp character varying(21), - eye boolean, - alt boolean, - longpost integer, - unblockable boolean, - bird integer, - fish boolean, - lootboxes_bought integer DEFAULT 0 NOT NULL, - progressivestack integer, - winnings integer DEFAULT 0 NOT NULL, - patron_utc integer DEFAULT 0 NOT NULL, - rehab integer, - house character varying(16), - subs_created integer DEFAULT 0 NOT NULL, - deflector integer, - reddit character varying(15) NOT NULL -); - - --- --- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.users_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id; - - --- --- Name: viewers; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.viewers ( - user_id integer NOT NULL, - viewer_id integer NOT NULL, - last_view_utc integer NOT NULL -); - - --- --- Name: votes; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.votes ( - user_id integer NOT NULL, - submission_id integer NOT NULL, - vote_type integer NOT NULL, - app_id integer, - "real" boolean DEFAULT true NOT NULL, - created_utc integer NOT NULL -); - - --- --- Name: award_relationships id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.award_relationships ALTER COLUMN id SET DEFAULT nextval('public.award_relationships_id_seq'::regclass); - - --- --- Name: badge_defs id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.badge_defs ALTER COLUMN id SET DEFAULT nextval('public.badge_defs_id_seq'::regclass); - - --- --- Name: comments id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.comments ALTER COLUMN id SET DEFAULT nextval('public.comments_id_seq'::regclass); - - --- --- Name: modactions id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.modactions ALTER COLUMN id SET DEFAULT nextval('public.modactions_id_seq'::regclass); - - --- --- Name: oauth_apps id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.oauth_apps ALTER COLUMN id SET DEFAULT nextval('public.oauth_apps_id_seq'::regclass); - - --- --- Name: submissions id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.submissions ALTER COLUMN id SET DEFAULT nextval('public.submissions_id_seq'::regclass); - - --- --- Name: users id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass); - - --- --- Name: alts alts_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.alts - ADD CONSTRAINT alts_pkey PRIMARY KEY (user1, user2); - - --- --- Name: award_relationships award_constraint; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.award_relationships - ADD CONSTRAINT award_constraint UNIQUE (user_id, submission_id, comment_id); - - --- --- Name: award_relationships award_relationships_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.award_relationships - ADD CONSTRAINT award_relationships_pkey PRIMARY KEY (id); - - --- --- Name: badge_defs badge_def_name_unique; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.badge_defs - ADD CONSTRAINT badge_def_name_unique UNIQUE (name); - - --- --- Name: badge_defs badge_defs_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.badge_defs - ADD CONSTRAINT badge_defs_pkey PRIMARY KEY (id); - - --- --- Name: badges badges_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.badges - ADD CONSTRAINT badges_pkey PRIMARY KEY (user_id, badge_id); - - --- --- Name: client_auths client_auths_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.client_auths - ADD CONSTRAINT client_auths_pkey PRIMARY KEY (user_id, oauth_client); - - --- --- Name: comment_save_relationship comment_save_relationship_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.comment_save_relationship - ADD CONSTRAINT comment_save_relationship_pkey PRIMARY KEY (user_id, comment_id); - - --- --- Name: commentflags commentflags_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.commentflags - ADD CONSTRAINT commentflags_pkey PRIMARY KEY (comment_id, user_id); - - --- --- Name: comments comments_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.comments - ADD CONSTRAINT comments_pkey PRIMARY KEY (id); - - --- --- Name: commentvotes commentvotes_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.commentvotes - ADD CONSTRAINT commentvotes_pkey PRIMARY KEY (comment_id, user_id); - - --- --- Name: banneddomains domain_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.banneddomains - ADD CONSTRAINT domain_pkey PRIMARY KEY (domain); - - --- --- Name: exiles exiles_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.exiles - ADD CONSTRAINT exiles_pkey PRIMARY KEY (user_id, sub); - - --- --- Name: flags flags_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.flags - ADD CONSTRAINT flags_pkey PRIMARY KEY (post_id, user_id); - - --- --- Name: follows follows_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.follows - ADD CONSTRAINT follows_pkey PRIMARY KEY (target_id, user_id); - - --- --- Name: marseys marseys_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.marseys - ADD CONSTRAINT marseys_pkey PRIMARY KEY (name); - - --- --- Name: modactions modactions_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.modactions - ADD CONSTRAINT modactions_pkey PRIMARY KEY (id); - - --- --- Name: mods mods_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.mods - ADD CONSTRAINT mods_pkey PRIMARY KEY (user_id, sub); - - --- --- Name: notifications notifications_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.notifications - ADD CONSTRAINT notifications_pkey PRIMARY KEY (user_id, comment_id); - - --- --- Name: oauth_apps oauth_apps_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.oauth_apps - ADD CONSTRAINT oauth_apps_pkey PRIMARY KEY (id); - - --- --- Name: users one_banner; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.users - ADD CONSTRAINT one_banner UNIQUE (bannerurl); - - --- --- Name: users one_discord_account; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.users - ADD CONSTRAINT one_discord_account UNIQUE (discord_id); - - --- --- Name: save_relationship save_relationship_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.save_relationship - ADD CONSTRAINT save_relationship_pkey PRIMARY KEY (user_id, submission_id); - - --- --- Name: sub_blocks sub_blocks_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.sub_blocks - ADD CONSTRAINT sub_blocks_pkey PRIMARY KEY (user_id, sub); - - --- --- Name: submissions submissions_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.submissions - ADD CONSTRAINT submissions_pkey PRIMARY KEY (id); - - --- --- Name: subs subs_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.subs - ADD CONSTRAINT subs_pkey PRIMARY KEY (name); - - --- --- Name: subscriptions subscriptions_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.subscriptions - ADD CONSTRAINT subscriptions_pkey PRIMARY KEY (submission_id, user_id); - - --- --- Name: users uid_unique; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.users - ADD CONSTRAINT uid_unique UNIQUE (id); - - --- --- Name: client_auths unique_access; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.client_auths - ADD CONSTRAINT unique_access UNIQUE (access_token); - - --- --- Name: oauth_apps unique_id; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.oauth_apps - ADD CONSTRAINT unique_id UNIQUE (client_id); - - --- --- Name: userblocks userblocks_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.userblocks - ADD CONSTRAINT userblocks_pkey PRIMARY KEY (user_id, target_id); - - --- --- Name: users users_original_username_key; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.users - ADD CONSTRAINT users_original_username_key UNIQUE (original_username); - - --- --- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.users - ADD CONSTRAINT users_pkey PRIMARY KEY (username); - - --- --- Name: users users_username_key; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.users - ADD CONSTRAINT users_username_key UNIQUE (username); - - --- --- Name: viewers viewers_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.viewers - ADD CONSTRAINT viewers_pkey PRIMARY KEY (user_id, viewer_id); - - --- --- Name: votes votes_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.votes - ADD CONSTRAINT votes_pkey PRIMARY KEY (submission_id, user_id); - - --- --- Name: alts_unique_combination; Type: INDEX; Schema: public; Owner: - --- - -CREATE UNIQUE INDEX alts_unique_combination ON public.alts USING btree (GREATEST(user1, user2), LEAST(user1, user2)); - - --- --- Name: alts_user2_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX alts_user2_idx ON public.alts USING btree (user2); - - --- --- Name: award_comment_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX award_comment_idx ON public.award_relationships USING btree (comment_id); - - --- --- Name: award_post_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX award_post_idx ON public.award_relationships USING btree (submission_id); - - --- --- Name: award_user_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX award_user_idx ON public.award_relationships USING btree (user_id); - - --- --- Name: badges_badge_id_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX badges_badge_id_idx ON public.badges USING btree (badge_id); - - --- --- Name: block_target_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX block_target_idx ON public.userblocks USING btree (target_id); - - --- --- Name: cflag_user_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX cflag_user_idx ON public.commentflags USING btree (user_id); - - --- --- Name: comment_parent_index; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX comment_parent_index ON public.comments USING btree (parent_comment_id); - - --- --- Name: comment_post_id_index; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX comment_post_id_index ON public.comments USING btree (parent_submission); - - --- --- Name: comments_user_index; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX comments_user_index ON public.comments USING btree (author_id); - - --- --- Name: commentvotes_comments_type_index; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX commentvotes_comments_type_index ON public.commentvotes USING btree (vote_type); - - --- --- Name: cvote_user_index; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX cvote_user_index ON public.commentvotes USING btree (user_id); - - --- --- Name: discord_id_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX discord_id_idx ON public.users USING btree (discord_id); - - --- --- Name: domains_domain_trgm_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX domains_domain_trgm_idx ON public.banneddomains USING gin (domain public.gin_trgm_ops); - - --- --- Name: fki_comment_approver_fkey; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX fki_comment_approver_fkey ON public.comments USING btree (is_approved); - - --- --- Name: fki_comment_save_relationship_comment_fkey; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX fki_comment_save_relationship_comment_fkey ON public.comment_save_relationship USING btree (comment_id); - - --- --- Name: fki_comment_sentto_fkey; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX fki_comment_sentto_fkey ON public.comments USING btree (sentto); - - --- --- Name: fki_exile_exiler_fkey; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX fki_exile_exiler_fkey ON public.exiles USING btree (exiler_id); - - --- --- Name: fki_exile_sub_fkey; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX fki_exile_sub_fkey ON public.exiles USING btree (sub); - - --- --- Name: fki_mod_sub_fkey; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX fki_mod_sub_fkey ON public.mods USING btree (sub); - - --- --- Name: fki_modactions_user_fkey; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX fki_modactions_user_fkey ON public.modactions USING btree (target_user_id); - - --- --- Name: fki_save_relationship_submission_fkey; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX fki_save_relationship_submission_fkey ON public.save_relationship USING btree (submission_id); - - --- --- Name: fki_sub_blocks_sub_fkey; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX fki_sub_blocks_sub_fkey ON public.sub_blocks USING btree (sub); - - --- --- Name: fki_submissions_approver_fkey; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX fki_submissions_approver_fkey ON public.submissions USING btree (is_approved); - - --- --- Name: fki_user_referrer_fkey; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX fki_user_referrer_fkey ON public.users USING btree (referred_by); - - --- --- Name: fki_view_viewer_fkey; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX fki_view_viewer_fkey ON public.viewers USING btree (viewer_id); - - --- --- Name: flag_user_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX flag_user_idx ON public.flags USING btree (user_id); - - --- --- Name: follow_user_id_index; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX follow_user_id_index ON public.follows USING btree (user_id); - - --- --- Name: marseys_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX marseys_idx ON public.marseys USING btree (name); - - --- --- Name: marseys_idx2; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX marseys_idx2 ON public.marseys USING btree (author_id); - - --- --- Name: marseys_idx3; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX marseys_idx3 ON public.marseys USING btree (count DESC); - - --- --- Name: modaction_action_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX modaction_action_idx ON public.modactions USING btree (kind); - - --- --- Name: modaction_cid_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX modaction_cid_idx ON public.modactions USING btree (target_comment_id); - - --- --- Name: modaction_id_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX modaction_id_idx ON public.modactions USING btree (id DESC); - - --- --- Name: modaction_pid_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX modaction_pid_idx ON public.modactions USING btree (target_submission_id); - - --- --- Name: notification_read_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX notification_read_idx ON public.notifications USING btree (read); - - --- --- Name: notifications_comment_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX notifications_comment_idx ON public.notifications USING btree (comment_id); - - --- --- Name: notifs_user_read_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX notifs_user_read_idx ON public.notifications USING btree (user_id, read); - - --- --- Name: post_app_id_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX post_app_id_idx ON public.submissions USING btree (app_id); - - --- --- Name: subimssion_binary_group_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX subimssion_binary_group_idx ON public.submissions USING btree (is_banned, deleted_utc, over_18); - - --- --- Name: submission_isbanned_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX submission_isbanned_idx ON public.submissions USING btree (is_banned); - - --- --- Name: submission_isdeleted_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX submission_isdeleted_idx ON public.submissions USING btree (deleted_utc); - - --- --- Name: submission_new_sort_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX submission_new_sort_idx ON public.submissions USING btree (is_banned, deleted_utc, created_utc DESC, over_18); - - --- --- Name: submission_pinned_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX submission_pinned_idx ON public.submissions USING btree (is_pinned); - - --- --- Name: submissions_author_index; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX submissions_author_index ON public.submissions USING btree (author_id); - - --- --- Name: submissions_created_utc_asc_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX submissions_created_utc_asc_idx ON public.submissions USING btree (created_utc NULLS FIRST); - - --- --- Name: submissions_created_utc_desc_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX submissions_created_utc_desc_idx ON public.submissions USING btree (created_utc DESC); - - --- --- Name: submissions_over18_index; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX submissions_over18_index ON public.submissions USING btree (over_18); - - --- --- Name: subs_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX subs_idx ON public.subs USING btree (name); - - --- --- Name: subscription_user_index; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX subscription_user_index ON public.subscriptions USING btree (user_id); - - --- --- Name: user_banned_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX user_banned_idx ON public.users USING btree (is_banned); - - --- --- Name: user_private_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX user_private_idx ON public.users USING btree (is_private); - - --- --- Name: users_created_utc_index; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX users_created_utc_index ON public.users USING btree (created_utc); - - --- --- Name: users_original_username_trgm_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX users_original_username_trgm_idx ON public.users USING gin (original_username public.gin_trgm_ops); - - --- --- Name: users_subs_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX users_subs_idx ON public.users USING btree (stored_subscriber_count); - - --- --- Name: users_unbanutc_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX users_unbanutc_idx ON public.users USING btree (unban_utc DESC); - - --- --- Name: users_username_trgm_idx; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX users_username_trgm_idx ON public.users USING gin (username public.gin_trgm_ops); - - --- --- Name: vote_user_index; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX vote_user_index ON public.votes USING btree (user_id); - - --- --- Name: votes_type_index; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX votes_type_index ON public.votes USING btree (vote_type); - - --- --- Name: alts alt_user1_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.alts - ADD CONSTRAINT alt_user1_fkey FOREIGN KEY (user1) REFERENCES public.users(id); - - --- --- Name: alts alt_user2_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.alts - ADD CONSTRAINT alt_user2_fkey FOREIGN KEY (user2) REFERENCES public.users(id); - - --- --- Name: oauth_apps app_author_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.oauth_apps - ADD CONSTRAINT app_author_id_fkey FOREIGN KEY (author_id) REFERENCES public.users(id); - - --- --- Name: award_relationships award_comment_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.award_relationships - ADD CONSTRAINT award_comment_fkey FOREIGN KEY (comment_id) REFERENCES public.comments(id); - - --- --- Name: award_relationships award_submission_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.award_relationships - ADD CONSTRAINT award_submission_fkey FOREIGN KEY (submission_id) REFERENCES public.submissions(id); - - --- --- Name: award_relationships award_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.award_relationships - ADD CONSTRAINT award_user_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); - - --- --- Name: badges badges_badge_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.badges - ADD CONSTRAINT badges_badge_id_fkey FOREIGN KEY (badge_id) REFERENCES public.badge_defs(id); - - --- --- Name: badges badges_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.badges - ADD CONSTRAINT badges_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); - - --- --- Name: userblocks block_target_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.userblocks - ADD CONSTRAINT block_target_fkey FOREIGN KEY (target_id) REFERENCES public.users(id); - - --- --- Name: userblocks block_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.userblocks - ADD CONSTRAINT block_user_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); - - --- --- Name: client_auths client_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.client_auths - ADD CONSTRAINT client_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); - - --- --- Name: comments comment_approver_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.comments - ADD CONSTRAINT comment_approver_fkey FOREIGN KEY (is_approved) REFERENCES public.users(id); - - --- --- Name: comments comment_parent_comment_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.comments - ADD CONSTRAINT comment_parent_comment_fkey FOREIGN KEY (parent_comment_id) REFERENCES public.comments(id); - - --- --- Name: comments comment_parent_submission_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.comments - ADD CONSTRAINT comment_parent_submission_fkey FOREIGN KEY (parent_submission) REFERENCES public.submissions(id); - - --- --- Name: comment_save_relationship comment_save_relationship_comment_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.comment_save_relationship - ADD CONSTRAINT comment_save_relationship_comment_fkey FOREIGN KEY (comment_id) REFERENCES public.comments(id) MATCH FULL; - - --- --- Name: comment_save_relationship comment_save_relationship_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.comment_save_relationship - ADD CONSTRAINT comment_save_relationship_user_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) MATCH FULL; - - --- --- Name: comments comment_sentto_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.comments - ADD CONSTRAINT comment_sentto_fkey FOREIGN KEY (sentto) REFERENCES public.users(id); - - --- --- Name: commentflags commentflags_comment_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.commentflags - ADD CONSTRAINT commentflags_comment_id_fkey FOREIGN KEY (comment_id) REFERENCES public.comments(id); - - --- --- Name: commentflags commentflags_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.commentflags - ADD CONSTRAINT commentflags_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); - - --- --- Name: comments comments_author_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.comments - ADD CONSTRAINT comments_author_id_fkey FOREIGN KEY (author_id) REFERENCES public.users(id); - - --- --- Name: commentvotes commentvote_comment_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.commentvotes - ADD CONSTRAINT commentvote_comment_fkey FOREIGN KEY (comment_id) REFERENCES public.comments(id) MATCH FULL; - - --- --- Name: commentvotes commentvote_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.commentvotes - ADD CONSTRAINT commentvote_user_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); - - --- --- Name: exiles exile_exiler_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.exiles - ADD CONSTRAINT exile_exiler_fkey FOREIGN KEY (exiler_id) REFERENCES public.users(id); - - --- --- Name: exiles exile_sub_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.exiles - ADD CONSTRAINT exile_sub_fkey FOREIGN KEY (sub) REFERENCES public.subs(name); - - --- --- Name: exiles exile_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.exiles - ADD CONSTRAINT exile_user_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); - - --- --- Name: flags flags_post_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.flags - ADD CONSTRAINT flags_post_id_fkey FOREIGN KEY (post_id) REFERENCES public.submissions(id); - - --- --- Name: flags flags_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.flags - ADD CONSTRAINT flags_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); - - --- --- Name: follows follow_target_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.follows - ADD CONSTRAINT follow_target_fkey FOREIGN KEY (target_id) REFERENCES public.users(id); - - --- --- Name: follows follow_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.follows - ADD CONSTRAINT follow_user_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); - - --- --- Name: marseys marsey_author_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.marseys - ADD CONSTRAINT marsey_author_fkey FOREIGN KEY (author_id) REFERENCES public.users(id); - - --- --- Name: mods mod_sub_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.mods - ADD CONSTRAINT mod_sub_fkey FOREIGN KEY (sub) REFERENCES public.subs(name); - - --- --- Name: modactions modactions_comment_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.modactions - ADD CONSTRAINT modactions_comment_fkey FOREIGN KEY (target_comment_id) REFERENCES public.comments(id); - - --- --- Name: modactions modactions_submission_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.modactions - ADD CONSTRAINT modactions_submission_fkey FOREIGN KEY (target_submission_id) REFERENCES public.submissions(id); - - --- --- Name: modactions modactions_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.modactions - ADD CONSTRAINT modactions_user_fkey FOREIGN KEY (target_user_id) REFERENCES public.users(id); - - --- --- Name: notifications notifications_comment_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.notifications - ADD CONSTRAINT notifications_comment_id_fkey FOREIGN KEY (comment_id) REFERENCES public.comments(id); - - --- --- Name: notifications notifications_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.notifications - ADD CONSTRAINT notifications_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); - - --- --- Name: client_auths oauth_client_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.client_auths - ADD CONSTRAINT oauth_client_fkey FOREIGN KEY (oauth_client) REFERENCES public.oauth_apps(id); - - --- --- Name: save_relationship save_relationship_submission_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.save_relationship - ADD CONSTRAINT save_relationship_submission_fkey FOREIGN KEY (submission_id) REFERENCES public.submissions(id) MATCH FULL; - - --- --- Name: save_relationship save_relationship_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.save_relationship - ADD CONSTRAINT save_relationship_user_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) MATCH FULL; - - --- --- Name: sub_blocks sub_blocks_sub_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.sub_blocks - ADD CONSTRAINT sub_blocks_sub_fkey FOREIGN KEY (sub) REFERENCES public.subs(name) MATCH FULL; - - --- --- Name: sub_blocks sub_blocks_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.sub_blocks - ADD CONSTRAINT sub_blocks_user_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) MATCH FULL; - - --- --- Name: submissions sub_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.submissions - ADD CONSTRAINT sub_fkey FOREIGN KEY (sub) REFERENCES public.subs(name); - - --- --- Name: submissions submissions_approver_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.submissions - ADD CONSTRAINT submissions_approver_fkey FOREIGN KEY (is_approved) REFERENCES public.users(id); - - --- --- Name: submissions submissions_author_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.submissions - ADD CONSTRAINT submissions_author_fkey FOREIGN KEY (author_id) REFERENCES public.users(id); - - --- --- Name: subscriptions subscription_submission_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.subscriptions - ADD CONSTRAINT subscription_submission_fkey FOREIGN KEY (submission_id) REFERENCES public.submissions(id); - - --- --- Name: subscriptions subscription_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.subscriptions - ADD CONSTRAINT subscription_user_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); - - --- --- Name: mods user_mod_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.mods - ADD CONSTRAINT user_mod_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); - - --- --- Name: users user_referrer_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.users - ADD CONSTRAINT user_referrer_fkey FOREIGN KEY (referred_by) REFERENCES public.users(id); - - --- --- Name: viewers view_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.viewers - ADD CONSTRAINT view_user_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); - - --- --- Name: viewers view_viewer_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.viewers - ADD CONSTRAINT view_viewer_fkey FOREIGN KEY (viewer_id) REFERENCES public.users(id); - - --- --- Name: votes vote_submission_key; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.votes - ADD CONSTRAINT vote_submission_key FOREIGN KEY (submission_id) REFERENCES public.submissions(id); - - --- --- Name: votes vote_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.votes - ADD CONSTRAINT vote_user_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); - From 9a23c195ed28cbb10628961481b28f524adf1fd7 Mon Sep 17 00:00:00 2001 From: TLSM Date: Fri, 20 May 2022 18:49:00 -0400 Subject: [PATCH 2/6] Fix overpermissive email regex. --- files/helpers/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/helpers/const.py b/files/helpers/const.py index 202f72989..9ce6daf06 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -824,7 +824,7 @@ emoji_regex3 = re.compile(f"(?([\w:~,()\-.#&\/=?@%;+]{5,250})<\/a>', flags=re.A) -email_regex = re.compile('[^@]+@[^@]+\.[^@]+', flags=re.A) +email_regex = re.compile('[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}', flags=re.A|re.I) utm_regex = re.compile('utm_[a-z]+=[a-z0-9_]+&', flags=re.A) utm_regex2 = re.compile('[?&]utm_[a-z]+=[a-z0-9_]+', flags=re.A) From 6fbaf2f15f5940ae9190ad2816434fd3041aa5f5 Mon Sep 17 00:00:00 2001 From: TLSM Date: Fri, 20 May 2022 19:15:44 -0400 Subject: [PATCH 3/6] Partially revert: cb1bb4e43b40, 2737a6ca479b. cb1bb4e43b40: Server cleaned out schema.sql for some reason and it was autocommitted by the sneed cron. This is why the tests fail. 2737a6ca479b: Originally pulled from themotte/rDrama @ 309bf44f12ba. In light of the fact this is breaking comment previews right now and the actual XSS threat is unclear, given we sanitize serverside, this is reverted until I find time to look at it. --- files/templates/comments.html | 2 +- files/templates/submit.html | 2 +- files/templates/userpage.html | 2 +- schema.sql | 1852 +++++++++++++++++++++++++++++++++ 4 files changed, 1855 insertions(+), 3 deletions(-) diff --git a/files/templates/comments.html b/files/templates/comments.html index 1e0a9aaea..7775278e0 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -845,7 +845,7 @@ {% endif %} {% if v %} - + {% endif %} diff --git a/files/templates/submit.html b/files/templates/submit.html index cf77a6b9c..d77afb4c7 100644 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -224,7 +224,7 @@ {% endif %} - + {% include "emoji_modal.html" %} diff --git a/files/templates/userpage.html b/files/templates/userpage.html index cb39d5339..66060637e 100644 --- a/files/templates/userpage.html +++ b/files/templates/userpage.html @@ -769,7 +769,7 @@ {% endif %} - + {% if v and v.id != u.id and '/comments' not in request.path %} diff --git a/schema.sql b/schema.sql index e69de29bb..b6cfe89eb 100644 --- a/schema.sql +++ b/schema.sql @@ -0,0 +1,1852 @@ +-- +-- PostgreSQL database dump +-- + +-- Dumped from database version 13.6 +-- Dumped by pg_dump version 14.2 (Ubuntu 14.2-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: fuzzystrmatch; Type: EXTENSION; Schema: -; Owner: - +-- + +CREATE EXTENSION IF NOT EXISTS fuzzystrmatch WITH SCHEMA public; + + +-- +-- Name: EXTENSION fuzzystrmatch; Type: COMMENT; Schema: -; Owner: - +-- + +COMMENT ON EXTENSION fuzzystrmatch IS 'determine similarities and distance between strings'; + + +-- +-- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner: - +-- + +CREATE EXTENSION IF NOT EXISTS pg_stat_statements WITH SCHEMA public; + + +-- +-- Name: EXTENSION pg_stat_statements; Type: COMMENT; Schema: -; Owner: - +-- + +COMMENT ON EXTENSION pg_stat_statements IS 'track planning and execution statistics of all SQL statements executed'; + + +-- +-- Name: pg_trgm; Type: EXTENSION; Schema: -; Owner: - +-- + +CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public; + + +-- +-- Name: EXTENSION pg_trgm; Type: COMMENT; Schema: -; Owner: - +-- + +COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching based on trigrams'; + + +SET default_tablespace = ''; + +SET default_table_access_method = heap; + +-- +-- Name: submissions; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.submissions ( + id integer NOT NULL, + author_id integer NOT NULL, + created_utc integer NOT NULL, + is_banned boolean DEFAULT false NOT NULL, + over_18 boolean DEFAULT false NOT NULL, + distinguish_level integer DEFAULT 0 NOT NULL, + deleted_utc integer DEFAULT 0 NOT NULL, + is_approved integer, + edited_utc integer DEFAULT 0 NOT NULL, + is_pinned boolean DEFAULT false NOT NULL, + upvotes integer DEFAULT 1 NOT NULL, + downvotes integer DEFAULT 0 NOT NULL, + app_id integer, + thumburl character varying(200), + private boolean DEFAULT false NOT NULL, + views integer DEFAULT 0 NOT NULL, + is_bot boolean DEFAULT false NOT NULL, + bannedfor boolean, + comment_count integer DEFAULT 0 NOT NULL, + club boolean DEFAULT false NOT NULL, + stickied character varying(40), + title character varying(500) NOT NULL, + url character varying(2083), + body character varying(20000), + body_html character varying(40000), + embed_url character varying(1500), + ban_reason character varying(25), + title_html character varying(1500) NOT NULL, + realupvotes integer, + flair character varying(350), + stickied_utc integer, + ghost boolean DEFAULT false NOT NULL, + sub character varying(20), + new boolean +); + + +-- +-- Name: bump_utc(public.submissions); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.bump_utc(public.submissions) RETURNS integer + LANGUAGE sql IMMUTABLE STRICT + AS $_$ + SELECT CREATED_UTC + FROM comments + WHERE parent_submission = $1.id + ORDER BY created_utc desc + LIMIT 1 + $_$; + + +-- +-- Name: alts; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.alts ( + user1 integer NOT NULL, + user2 integer NOT NULL, + is_manual boolean DEFAULT false NOT NULL, + CONSTRAINT alts_cant_be_equal CHECK ((user1 <> user2)) +); + + +-- +-- Name: award_relationships; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.award_relationships ( + id integer NOT NULL, + user_id integer NOT NULL, + submission_id integer, + comment_id integer, + kind character varying(20) NOT NULL +); + + +-- +-- Name: award_relationships_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.award_relationships_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: award_relationships_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.award_relationships_id_seq OWNED BY public.award_relationships.id; + + +-- +-- Name: badge_defs; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.badge_defs ( + id integer NOT NULL, + name character varying(50) NOT NULL, + description character varying(200) +); + + +-- +-- Name: badge_defs_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.badge_defs_id_seq + AS integer + START WITH 106 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: badge_defs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.badge_defs_id_seq OWNED BY public.badge_defs.id; + + +-- +-- Name: badges; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.badges ( + badge_id integer NOT NULL, + user_id integer NOT NULL, + description character varying(256), + url character varying(256) +); + + +-- +-- Name: banneddomains; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.banneddomains ( + domain character varying(100) NOT NULL, + reason character varying(100) NOT NULL +); + + +-- +-- Name: client_auths; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.client_auths ( + user_id integer NOT NULL, + oauth_client integer NOT NULL, + access_token character(128) NOT NULL +); + + +-- +-- Name: comment_save_relationship; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.comment_save_relationship ( + user_id integer NOT NULL, + comment_id integer NOT NULL +); + + +-- +-- Name: commentflags; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.commentflags ( + user_id integer NOT NULL, + comment_id integer NOT NULL, + reason character varying(350), + created_utc integer NOT NULL +); + + +-- +-- Name: comments; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.comments ( + id integer NOT NULL, + author_id integer NOT NULL, + created_utc integer NOT NULL, + parent_submission integer, + is_banned boolean DEFAULT false NOT NULL, + distinguish_level integer DEFAULT 0 NOT NULL, + edited_utc integer DEFAULT 0 NOT NULL, + deleted_utc integer DEFAULT 0 NOT NULL, + is_approved integer, + level integer DEFAULT 0 NOT NULL, + parent_comment_id integer, + over_18 boolean DEFAULT false NOT NULL, + upvotes integer DEFAULT 1 NOT NULL, + downvotes integer DEFAULT 0 NOT NULL, + is_bot boolean DEFAULT false NOT NULL, + app_id integer, + sentto integer, + bannedfor boolean, + is_pinned character varying(40), + body character varying(10000), + body_html character varying(40000), + ban_reason character varying(25), + realupvotes integer DEFAULT 1 NOT NULL, + top_comment_id integer, + is_pinned_utc integer, + ghost boolean DEFAULT false NOT NULL, + slots_result character varying(32), + blackjack_result character varying(860), + treasure_amount character varying(10), + wordle_result character varying(115) +); + + +-- +-- Name: comments_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.comments_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: comments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.comments_id_seq OWNED BY public.comments.id; + + +-- +-- Name: commentvotes; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.commentvotes ( + comment_id integer NOT NULL, + vote_type integer NOT NULL, + user_id integer NOT NULL, + app_id integer, + "real" boolean DEFAULT true NOT NULL, + created_utc integer NOT NULL +); + + +-- +-- Name: exiles; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.exiles ( + user_id integer NOT NULL, + sub character varying(20) NOT NULL, + exiler_id integer NOT NULL +); + + +-- +-- Name: flags; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.flags ( + user_id integer NOT NULL, + post_id integer NOT NULL, + reason character varying(350), + created_utc integer NOT NULL +); + + +-- +-- Name: follows; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.follows ( + user_id integer NOT NULL, + target_id integer NOT NULL, + created_utc integer NOT NULL +); + + +-- +-- Name: marseys; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.marseys ( + name character varying(30) NOT NULL, + author_id integer NOT NULL, + tags character varying(200) NOT NULL, + count integer DEFAULT 0 NOT NULL +); + + +-- +-- Name: modactions; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.modactions ( + id integer NOT NULL, + user_id integer, + target_user_id integer, + target_submission_id integer, + target_comment_id integer, + created_utc integer NOT NULL, + kind character varying(32) DEFAULT NULL::character varying, + _note character varying(256) DEFAULT NULL::character varying +); + + +-- +-- Name: modactions_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.modactions_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: modactions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.modactions_id_seq OWNED BY public.modactions.id; + + +-- +-- Name: mods; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.mods ( + user_id integer NOT NULL, + sub character varying(20) NOT NULL, + created_utc integer NOT NULL +); + + +-- +-- Name: notifications; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.notifications ( + user_id integer NOT NULL, + comment_id integer NOT NULL, + read boolean NOT NULL, + created_utc integer NOT NULL +); + + +-- +-- Name: oauth_apps; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.oauth_apps ( + id integer NOT NULL, + client_id character(64), + app_name character varying(50) NOT NULL, + redirect_uri character varying(4096) NOT NULL, + author_id integer NOT NULL, + description character varying(256) NOT NULL +); + + +-- +-- Name: oauth_apps_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.oauth_apps_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: oauth_apps_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.oauth_apps_id_seq OWNED BY public.oauth_apps.id; + + +-- +-- Name: save_relationship; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.save_relationship ( + submission_id integer NOT NULL, + user_id integer NOT NULL +); + + +-- +-- Name: sub_blocks; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.sub_blocks ( + user_id integer NOT NULL, + sub character varying(20) NOT NULL +); + + +-- +-- Name: submissions_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.submissions_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: submissions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.submissions_id_seq OWNED BY public.submissions.id; + + +-- +-- Name: subs; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.subs ( + name character varying(20) NOT NULL, + sidebar character varying(500), + sidebar_html character varying(1000), + sidebarurl character varying(60), + bannerurl character varying(60), + css character varying(4000) +); + + +-- +-- Name: subscriptions; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.subscriptions ( + user_id integer NOT NULL, + submission_id integer NOT NULL +); + + +-- +-- Name: userblocks; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.userblocks ( + user_id integer NOT NULL, + target_id integer NOT NULL +); + + +-- +-- Name: users; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.users ( + id integer NOT NULL, + username character varying(255) NOT NULL, + email character varying(255), + passhash character varying(255) NOT NULL, + created_utc integer NOT NULL, + admin_level integer DEFAULT 0 NOT NULL, + over_18 boolean DEFAULT false NOT NULL, + is_activated boolean DEFAULT false NOT NULL, + bio character varying(1500), + bio_html character varying(10000), + referred_by integer, + is_banned integer DEFAULT 0 NOT NULL, + ban_reason character varying(256), + login_nonce integer DEFAULT 0 NOT NULL, + reserved character varying(256), + mfa_secret character varying(32), + is_private boolean DEFAULT false NOT NULL, + unban_utc integer DEFAULT 0 NOT NULL, + is_nofollow boolean DEFAULT false NOT NULL, + custom_filter_list character varying(1000) DEFAULT ''::character varying, + discord_id character varying(64), + stored_subscriber_count integer DEFAULT 0 NOT NULL, + ban_evade integer DEFAULT 0 NOT NULL, + original_username character varying(255), + customtitle character varying(1000), + defaultsorting character varying(15) DEFAULT 'hot'::character varying NOT NULL, + defaulttime character varying(5) NOT NULL, + namecolor character varying(6) NOT NULL, + titlecolor character varying(6) NOT NULL, + profileurl character varying(65), + bannerurl character varying(65), + hidevotedon boolean DEFAULT false NOT NULL, + newtab boolean DEFAULT false NOT NULL, + flairchanged integer, + defaultsortingcomments character varying(15) DEFAULT 'top'::character varying NOT NULL, + theme character varying(15) NOT NULL, + song character varying(50), + slurreplacer boolean DEFAULT true NOT NULL, + shadowbanned character varying(25), + newtabexternal boolean DEFAULT true NOT NULL, + customtitleplain character varying(100), + themecolor character varying(6) NOT NULL, + changelogsub boolean DEFAULT false NOT NULL, + css character varying(4000), + profilecss character varying(4000), + coins integer DEFAULT 0 NOT NULL, + agendaposter integer DEFAULT 0 NOT NULL, + post_count integer DEFAULT 0 NOT NULL, + comment_count integer DEFAULT 0 NOT NULL, + highres character varying(60), + patron integer DEFAULT 0 NOT NULL, + controversial boolean DEFAULT false NOT NULL, + background character varying(20), + verified character varying(100), + cardview boolean NOT NULL, + received_award_count integer DEFAULT 0 NOT NULL, + highlightcomments boolean DEFAULT true NOT NULL, + nitter boolean, + truecoins integer DEFAULT 0 NOT NULL, + club_allowed boolean, + frontsize integer DEFAULT 25 NOT NULL, + coins_spent integer DEFAULT 0 NOT NULL, + procoins integer DEFAULT 0 NOT NULL, + mute boolean, + unmutable boolean, + verifiedcolor character varying(6), + marseyawarded integer, + sig character varying(200), + sig_html character varying(1000), + friends character varying(500), + friends_html character varying(2000), + sigs_disabled boolean, + enemies character varying(500), + enemies_html character varying(2000), + fp character varying(21), + eye boolean, + alt boolean, + longpost integer, + unblockable boolean, + bird integer, + fish boolean, + lootboxes_bought integer DEFAULT 0 NOT NULL, + progressivestack integer, + winnings integer DEFAULT 0 NOT NULL, + patron_utc integer DEFAULT 0 NOT NULL, + rehab integer, + house character varying(16), + subs_created integer DEFAULT 0 NOT NULL, + deflector integer, + reddit character varying(15) NOT NULL +); + + +-- +-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.users_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id; + + +-- +-- Name: viewers; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.viewers ( + user_id integer NOT NULL, + viewer_id integer NOT NULL, + last_view_utc integer NOT NULL +); + + +-- +-- Name: votes; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.votes ( + user_id integer NOT NULL, + submission_id integer NOT NULL, + vote_type integer NOT NULL, + app_id integer, + "real" boolean DEFAULT true NOT NULL, + created_utc integer NOT NULL +); + + +-- +-- Name: award_relationships id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.award_relationships ALTER COLUMN id SET DEFAULT nextval('public.award_relationships_id_seq'::regclass); + + +-- +-- Name: badge_defs id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.badge_defs ALTER COLUMN id SET DEFAULT nextval('public.badge_defs_id_seq'::regclass); + + +-- +-- Name: comments id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.comments ALTER COLUMN id SET DEFAULT nextval('public.comments_id_seq'::regclass); + + +-- +-- Name: modactions id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.modactions ALTER COLUMN id SET DEFAULT nextval('public.modactions_id_seq'::regclass); + + +-- +-- Name: oauth_apps id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.oauth_apps ALTER COLUMN id SET DEFAULT nextval('public.oauth_apps_id_seq'::regclass); + + +-- +-- Name: submissions id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.submissions ALTER COLUMN id SET DEFAULT nextval('public.submissions_id_seq'::regclass); + + +-- +-- Name: users id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass); + + +-- +-- Name: alts alts_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.alts + ADD CONSTRAINT alts_pkey PRIMARY KEY (user1, user2); + + +-- +-- Name: award_relationships award_constraint; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.award_relationships + ADD CONSTRAINT award_constraint UNIQUE (user_id, submission_id, comment_id); + + +-- +-- Name: award_relationships award_relationships_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.award_relationships + ADD CONSTRAINT award_relationships_pkey PRIMARY KEY (id); + + +-- +-- Name: badge_defs badge_def_name_unique; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.badge_defs + ADD CONSTRAINT badge_def_name_unique UNIQUE (name); + + +-- +-- Name: badge_defs badge_defs_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.badge_defs + ADD CONSTRAINT badge_defs_pkey PRIMARY KEY (id); + + +-- +-- Name: badges badges_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.badges + ADD CONSTRAINT badges_pkey PRIMARY KEY (user_id, badge_id); + + +-- +-- Name: client_auths client_auths_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.client_auths + ADD CONSTRAINT client_auths_pkey PRIMARY KEY (user_id, oauth_client); + + +-- +-- Name: comment_save_relationship comment_save_relationship_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.comment_save_relationship + ADD CONSTRAINT comment_save_relationship_pkey PRIMARY KEY (user_id, comment_id); + + +-- +-- Name: commentflags commentflags_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.commentflags + ADD CONSTRAINT commentflags_pkey PRIMARY KEY (comment_id, user_id); + + +-- +-- Name: comments comments_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.comments + ADD CONSTRAINT comments_pkey PRIMARY KEY (id); + + +-- +-- Name: commentvotes commentvotes_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.commentvotes + ADD CONSTRAINT commentvotes_pkey PRIMARY KEY (comment_id, user_id); + + +-- +-- Name: banneddomains domain_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.banneddomains + ADD CONSTRAINT domain_pkey PRIMARY KEY (domain); + + +-- +-- Name: exiles exiles_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.exiles + ADD CONSTRAINT exiles_pkey PRIMARY KEY (user_id, sub); + + +-- +-- Name: flags flags_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.flags + ADD CONSTRAINT flags_pkey PRIMARY KEY (post_id, user_id); + + +-- +-- Name: follows follows_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.follows + ADD CONSTRAINT follows_pkey PRIMARY KEY (target_id, user_id); + + +-- +-- Name: marseys marseys_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.marseys + ADD CONSTRAINT marseys_pkey PRIMARY KEY (name); + + +-- +-- Name: modactions modactions_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.modactions + ADD CONSTRAINT modactions_pkey PRIMARY KEY (id); + + +-- +-- Name: mods mods_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.mods + ADD CONSTRAINT mods_pkey PRIMARY KEY (user_id, sub); + + +-- +-- Name: notifications notifications_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.notifications + ADD CONSTRAINT notifications_pkey PRIMARY KEY (user_id, comment_id); + + +-- +-- Name: oauth_apps oauth_apps_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.oauth_apps + ADD CONSTRAINT oauth_apps_pkey PRIMARY KEY (id); + + +-- +-- Name: users one_banner; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.users + ADD CONSTRAINT one_banner UNIQUE (bannerurl); + + +-- +-- Name: users one_discord_account; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.users + ADD CONSTRAINT one_discord_account UNIQUE (discord_id); + + +-- +-- Name: save_relationship save_relationship_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.save_relationship + ADD CONSTRAINT save_relationship_pkey PRIMARY KEY (user_id, submission_id); + + +-- +-- Name: sub_blocks sub_blocks_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.sub_blocks + ADD CONSTRAINT sub_blocks_pkey PRIMARY KEY (user_id, sub); + + +-- +-- Name: submissions submissions_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.submissions + ADD CONSTRAINT submissions_pkey PRIMARY KEY (id); + + +-- +-- Name: subs subs_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.subs + ADD CONSTRAINT subs_pkey PRIMARY KEY (name); + + +-- +-- Name: subscriptions subscriptions_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.subscriptions + ADD CONSTRAINT subscriptions_pkey PRIMARY KEY (submission_id, user_id); + + +-- +-- Name: users uid_unique; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.users + ADD CONSTRAINT uid_unique UNIQUE (id); + + +-- +-- Name: client_auths unique_access; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.client_auths + ADD CONSTRAINT unique_access UNIQUE (access_token); + + +-- +-- Name: oauth_apps unique_id; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.oauth_apps + ADD CONSTRAINT unique_id UNIQUE (client_id); + + +-- +-- Name: userblocks userblocks_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.userblocks + ADD CONSTRAINT userblocks_pkey PRIMARY KEY (user_id, target_id); + + +-- +-- Name: users users_original_username_key; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.users + ADD CONSTRAINT users_original_username_key UNIQUE (original_username); + + +-- +-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.users + ADD CONSTRAINT users_pkey PRIMARY KEY (username); + + +-- +-- Name: users users_username_key; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.users + ADD CONSTRAINT users_username_key UNIQUE (username); + + +-- +-- Name: viewers viewers_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.viewers + ADD CONSTRAINT viewers_pkey PRIMARY KEY (user_id, viewer_id); + + +-- +-- Name: votes votes_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.votes + ADD CONSTRAINT votes_pkey PRIMARY KEY (submission_id, user_id); + + +-- +-- Name: alts_unique_combination; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX alts_unique_combination ON public.alts USING btree (GREATEST(user1, user2), LEAST(user1, user2)); + + +-- +-- Name: alts_user2_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX alts_user2_idx ON public.alts USING btree (user2); + + +-- +-- Name: award_comment_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX award_comment_idx ON public.award_relationships USING btree (comment_id); + + +-- +-- Name: award_post_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX award_post_idx ON public.award_relationships USING btree (submission_id); + + +-- +-- Name: award_user_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX award_user_idx ON public.award_relationships USING btree (user_id); + + +-- +-- Name: badges_badge_id_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX badges_badge_id_idx ON public.badges USING btree (badge_id); + + +-- +-- Name: block_target_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX block_target_idx ON public.userblocks USING btree (target_id); + + +-- +-- Name: cflag_user_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX cflag_user_idx ON public.commentflags USING btree (user_id); + + +-- +-- Name: comment_parent_index; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX comment_parent_index ON public.comments USING btree (parent_comment_id); + + +-- +-- Name: comment_post_id_index; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX comment_post_id_index ON public.comments USING btree (parent_submission); + + +-- +-- Name: comments_user_index; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX comments_user_index ON public.comments USING btree (author_id); + + +-- +-- Name: commentvotes_comments_type_index; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX commentvotes_comments_type_index ON public.commentvotes USING btree (vote_type); + + +-- +-- Name: cvote_user_index; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX cvote_user_index ON public.commentvotes USING btree (user_id); + + +-- +-- Name: discord_id_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX discord_id_idx ON public.users USING btree (discord_id); + + +-- +-- Name: domains_domain_trgm_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX domains_domain_trgm_idx ON public.banneddomains USING gin (domain public.gin_trgm_ops); + + +-- +-- Name: fki_comment_approver_fkey; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX fki_comment_approver_fkey ON public.comments USING btree (is_approved); + + +-- +-- Name: fki_comment_save_relationship_comment_fkey; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX fki_comment_save_relationship_comment_fkey ON public.comment_save_relationship USING btree (comment_id); + + +-- +-- Name: fki_comment_sentto_fkey; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX fki_comment_sentto_fkey ON public.comments USING btree (sentto); + + +-- +-- Name: fki_exile_exiler_fkey; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX fki_exile_exiler_fkey ON public.exiles USING btree (exiler_id); + + +-- +-- Name: fki_exile_sub_fkey; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX fki_exile_sub_fkey ON public.exiles USING btree (sub); + + +-- +-- Name: fki_mod_sub_fkey; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX fki_mod_sub_fkey ON public.mods USING btree (sub); + + +-- +-- Name: fki_modactions_user_fkey; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX fki_modactions_user_fkey ON public.modactions USING btree (target_user_id); + + +-- +-- Name: fki_save_relationship_submission_fkey; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX fki_save_relationship_submission_fkey ON public.save_relationship USING btree (submission_id); + + +-- +-- Name: fki_sub_blocks_sub_fkey; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX fki_sub_blocks_sub_fkey ON public.sub_blocks USING btree (sub); + + +-- +-- Name: fki_submissions_approver_fkey; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX fki_submissions_approver_fkey ON public.submissions USING btree (is_approved); + + +-- +-- Name: fki_user_referrer_fkey; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX fki_user_referrer_fkey ON public.users USING btree (referred_by); + + +-- +-- Name: fki_view_viewer_fkey; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX fki_view_viewer_fkey ON public.viewers USING btree (viewer_id); + + +-- +-- Name: flag_user_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX flag_user_idx ON public.flags USING btree (user_id); + + +-- +-- Name: follow_user_id_index; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX follow_user_id_index ON public.follows USING btree (user_id); + + +-- +-- Name: marseys_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX marseys_idx ON public.marseys USING btree (name); + + +-- +-- Name: marseys_idx2; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX marseys_idx2 ON public.marseys USING btree (author_id); + + +-- +-- Name: marseys_idx3; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX marseys_idx3 ON public.marseys USING btree (count DESC); + + +-- +-- Name: modaction_action_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX modaction_action_idx ON public.modactions USING btree (kind); + + +-- +-- Name: modaction_cid_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX modaction_cid_idx ON public.modactions USING btree (target_comment_id); + + +-- +-- Name: modaction_id_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX modaction_id_idx ON public.modactions USING btree (id DESC); + + +-- +-- Name: modaction_pid_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX modaction_pid_idx ON public.modactions USING btree (target_submission_id); + + +-- +-- Name: notification_read_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX notification_read_idx ON public.notifications USING btree (read); + + +-- +-- Name: notifications_comment_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX notifications_comment_idx ON public.notifications USING btree (comment_id); + + +-- +-- Name: notifs_user_read_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX notifs_user_read_idx ON public.notifications USING btree (user_id, read); + + +-- +-- Name: post_app_id_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX post_app_id_idx ON public.submissions USING btree (app_id); + + +-- +-- Name: subimssion_binary_group_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX subimssion_binary_group_idx ON public.submissions USING btree (is_banned, deleted_utc, over_18); + + +-- +-- Name: submission_isbanned_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX submission_isbanned_idx ON public.submissions USING btree (is_banned); + + +-- +-- Name: submission_isdeleted_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX submission_isdeleted_idx ON public.submissions USING btree (deleted_utc); + + +-- +-- Name: submission_new_sort_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX submission_new_sort_idx ON public.submissions USING btree (is_banned, deleted_utc, created_utc DESC, over_18); + + +-- +-- Name: submission_pinned_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX submission_pinned_idx ON public.submissions USING btree (is_pinned); + + +-- +-- Name: submissions_author_index; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX submissions_author_index ON public.submissions USING btree (author_id); + + +-- +-- Name: submissions_created_utc_asc_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX submissions_created_utc_asc_idx ON public.submissions USING btree (created_utc NULLS FIRST); + + +-- +-- Name: submissions_created_utc_desc_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX submissions_created_utc_desc_idx ON public.submissions USING btree (created_utc DESC); + + +-- +-- Name: submissions_over18_index; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX submissions_over18_index ON public.submissions USING btree (over_18); + + +-- +-- Name: subs_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX subs_idx ON public.subs USING btree (name); + + +-- +-- Name: subscription_user_index; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX subscription_user_index ON public.subscriptions USING btree (user_id); + + +-- +-- Name: user_banned_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX user_banned_idx ON public.users USING btree (is_banned); + + +-- +-- Name: user_private_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX user_private_idx ON public.users USING btree (is_private); + + +-- +-- Name: users_created_utc_index; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX users_created_utc_index ON public.users USING btree (created_utc); + + +-- +-- Name: users_original_username_trgm_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX users_original_username_trgm_idx ON public.users USING gin (original_username public.gin_trgm_ops); + + +-- +-- Name: users_subs_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX users_subs_idx ON public.users USING btree (stored_subscriber_count); + + +-- +-- Name: users_unbanutc_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX users_unbanutc_idx ON public.users USING btree (unban_utc DESC); + + +-- +-- Name: users_username_trgm_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX users_username_trgm_idx ON public.users USING gin (username public.gin_trgm_ops); + + +-- +-- Name: vote_user_index; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX vote_user_index ON public.votes USING btree (user_id); + + +-- +-- Name: votes_type_index; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX votes_type_index ON public.votes USING btree (vote_type); + + +-- +-- Name: alts alt_user1_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.alts + ADD CONSTRAINT alt_user1_fkey FOREIGN KEY (user1) REFERENCES public.users(id); + + +-- +-- Name: alts alt_user2_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.alts + ADD CONSTRAINT alt_user2_fkey FOREIGN KEY (user2) REFERENCES public.users(id); + + +-- +-- Name: oauth_apps app_author_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.oauth_apps + ADD CONSTRAINT app_author_id_fkey FOREIGN KEY (author_id) REFERENCES public.users(id); + + +-- +-- Name: award_relationships award_comment_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.award_relationships + ADD CONSTRAINT award_comment_fkey FOREIGN KEY (comment_id) REFERENCES public.comments(id); + + +-- +-- Name: award_relationships award_submission_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.award_relationships + ADD CONSTRAINT award_submission_fkey FOREIGN KEY (submission_id) REFERENCES public.submissions(id); + + +-- +-- Name: award_relationships award_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.award_relationships + ADD CONSTRAINT award_user_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); + + +-- +-- Name: badges badges_badge_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.badges + ADD CONSTRAINT badges_badge_id_fkey FOREIGN KEY (badge_id) REFERENCES public.badge_defs(id); + + +-- +-- Name: badges badges_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.badges + ADD CONSTRAINT badges_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); + + +-- +-- Name: userblocks block_target_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.userblocks + ADD CONSTRAINT block_target_fkey FOREIGN KEY (target_id) REFERENCES public.users(id); + + +-- +-- Name: userblocks block_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.userblocks + ADD CONSTRAINT block_user_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); + + +-- +-- Name: client_auths client_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.client_auths + ADD CONSTRAINT client_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); + + +-- +-- Name: comments comment_approver_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.comments + ADD CONSTRAINT comment_approver_fkey FOREIGN KEY (is_approved) REFERENCES public.users(id); + + +-- +-- Name: comments comment_parent_comment_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.comments + ADD CONSTRAINT comment_parent_comment_fkey FOREIGN KEY (parent_comment_id) REFERENCES public.comments(id); + + +-- +-- Name: comments comment_parent_submission_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.comments + ADD CONSTRAINT comment_parent_submission_fkey FOREIGN KEY (parent_submission) REFERENCES public.submissions(id); + + +-- +-- Name: comment_save_relationship comment_save_relationship_comment_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.comment_save_relationship + ADD CONSTRAINT comment_save_relationship_comment_fkey FOREIGN KEY (comment_id) REFERENCES public.comments(id) MATCH FULL; + + +-- +-- Name: comment_save_relationship comment_save_relationship_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.comment_save_relationship + ADD CONSTRAINT comment_save_relationship_user_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) MATCH FULL; + + +-- +-- Name: comments comment_sentto_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.comments + ADD CONSTRAINT comment_sentto_fkey FOREIGN KEY (sentto) REFERENCES public.users(id); + + +-- +-- Name: commentflags commentflags_comment_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.commentflags + ADD CONSTRAINT commentflags_comment_id_fkey FOREIGN KEY (comment_id) REFERENCES public.comments(id); + + +-- +-- Name: commentflags commentflags_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.commentflags + ADD CONSTRAINT commentflags_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); + + +-- +-- Name: comments comments_author_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.comments + ADD CONSTRAINT comments_author_id_fkey FOREIGN KEY (author_id) REFERENCES public.users(id); + + +-- +-- Name: commentvotes commentvote_comment_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.commentvotes + ADD CONSTRAINT commentvote_comment_fkey FOREIGN KEY (comment_id) REFERENCES public.comments(id) MATCH FULL; + + +-- +-- Name: commentvotes commentvote_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.commentvotes + ADD CONSTRAINT commentvote_user_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); + + +-- +-- Name: exiles exile_exiler_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.exiles + ADD CONSTRAINT exile_exiler_fkey FOREIGN KEY (exiler_id) REFERENCES public.users(id); + + +-- +-- Name: exiles exile_sub_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.exiles + ADD CONSTRAINT exile_sub_fkey FOREIGN KEY (sub) REFERENCES public.subs(name); + + +-- +-- Name: exiles exile_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.exiles + ADD CONSTRAINT exile_user_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); + + +-- +-- Name: flags flags_post_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.flags + ADD CONSTRAINT flags_post_id_fkey FOREIGN KEY (post_id) REFERENCES public.submissions(id); + + +-- +-- Name: flags flags_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.flags + ADD CONSTRAINT flags_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); + + +-- +-- Name: follows follow_target_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.follows + ADD CONSTRAINT follow_target_fkey FOREIGN KEY (target_id) REFERENCES public.users(id); + + +-- +-- Name: follows follow_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.follows + ADD CONSTRAINT follow_user_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); + + +-- +-- Name: marseys marsey_author_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.marseys + ADD CONSTRAINT marsey_author_fkey FOREIGN KEY (author_id) REFERENCES public.users(id); + + +-- +-- Name: mods mod_sub_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.mods + ADD CONSTRAINT mod_sub_fkey FOREIGN KEY (sub) REFERENCES public.subs(name); + + +-- +-- Name: modactions modactions_comment_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.modactions + ADD CONSTRAINT modactions_comment_fkey FOREIGN KEY (target_comment_id) REFERENCES public.comments(id); + + +-- +-- Name: modactions modactions_submission_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.modactions + ADD CONSTRAINT modactions_submission_fkey FOREIGN KEY (target_submission_id) REFERENCES public.submissions(id); + + +-- +-- Name: modactions modactions_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.modactions + ADD CONSTRAINT modactions_user_fkey FOREIGN KEY (target_user_id) REFERENCES public.users(id); + + +-- +-- Name: notifications notifications_comment_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.notifications + ADD CONSTRAINT notifications_comment_id_fkey FOREIGN KEY (comment_id) REFERENCES public.comments(id); + + +-- +-- Name: notifications notifications_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.notifications + ADD CONSTRAINT notifications_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); + + +-- +-- Name: client_auths oauth_client_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.client_auths + ADD CONSTRAINT oauth_client_fkey FOREIGN KEY (oauth_client) REFERENCES public.oauth_apps(id); + + +-- +-- Name: save_relationship save_relationship_submission_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.save_relationship + ADD CONSTRAINT save_relationship_submission_fkey FOREIGN KEY (submission_id) REFERENCES public.submissions(id) MATCH FULL; + + +-- +-- Name: save_relationship save_relationship_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.save_relationship + ADD CONSTRAINT save_relationship_user_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) MATCH FULL; + + +-- +-- Name: sub_blocks sub_blocks_sub_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.sub_blocks + ADD CONSTRAINT sub_blocks_sub_fkey FOREIGN KEY (sub) REFERENCES public.subs(name) MATCH FULL; + + +-- +-- Name: sub_blocks sub_blocks_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.sub_blocks + ADD CONSTRAINT sub_blocks_user_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) MATCH FULL; + + +-- +-- Name: submissions sub_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.submissions + ADD CONSTRAINT sub_fkey FOREIGN KEY (sub) REFERENCES public.subs(name); + + +-- +-- Name: submissions submissions_approver_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.submissions + ADD CONSTRAINT submissions_approver_fkey FOREIGN KEY (is_approved) REFERENCES public.users(id); + + +-- +-- Name: submissions submissions_author_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.submissions + ADD CONSTRAINT submissions_author_fkey FOREIGN KEY (author_id) REFERENCES public.users(id); + + +-- +-- Name: subscriptions subscription_submission_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.subscriptions + ADD CONSTRAINT subscription_submission_fkey FOREIGN KEY (submission_id) REFERENCES public.submissions(id); + + +-- +-- Name: subscriptions subscription_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.subscriptions + ADD CONSTRAINT subscription_user_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); + + +-- +-- Name: mods user_mod_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.mods + ADD CONSTRAINT user_mod_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); + + +-- +-- Name: users user_referrer_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.users + ADD CONSTRAINT user_referrer_fkey FOREIGN KEY (referred_by) REFERENCES public.users(id); + + +-- +-- Name: viewers view_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.viewers + ADD CONSTRAINT view_user_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); + + +-- +-- Name: viewers view_viewer_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.viewers + ADD CONSTRAINT view_viewer_fkey FOREIGN KEY (viewer_id) REFERENCES public.users(id); + + +-- +-- Name: votes vote_submission_key; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.votes + ADD CONSTRAINT vote_submission_key FOREIGN KEY (submission_id) REFERENCES public.submissions(id); + + +-- +-- Name: votes vote_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.votes + ADD CONSTRAINT vote_user_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); + From 15f811f2fc5bc1badd22ccecb071260eb4c30411 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 21 May 2022 00:00:01 +0000 Subject: [PATCH 4/6] sneed --- schema.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema.sql b/schema.sql index b6cfe89eb..bf01d0004 100644 --- a/schema.sql +++ b/schema.sql @@ -2,7 +2,7 @@ -- PostgreSQL database dump -- --- Dumped from database version 13.6 +-- Dumped from database version 13.7 -- Dumped by pg_dump version 14.2 (Ubuntu 14.2-1.pgdg20.04+1) SET statement_timeout = 0; From 3d9c302faed5d88e2a70928c086119d87c156509 Mon Sep 17 00:00:00 2001 From: TLSM Date: Fri, 20 May 2022 23:08:20 -0400 Subject: [PATCH 5/6] Blackjack: add five card charlie rule. --- files/helpers/blackjack.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/files/helpers/blackjack.py b/files/helpers/blackjack.py index 6b08d90d5..d560aad86 100644 --- a/files/helpers/blackjack.py +++ b/files/helpers/blackjack.py @@ -93,10 +93,14 @@ def player_hit(from_comment, did_double_down=False): if player_value == -1: status = 'bust' apply_game_result(from_comment, wager, status, kind) + elif len(player_hand) >= 5: + status = 'won' + apply_game_result(from_comment, wager, status, kind) from_comment.blackjack_result = format_all(player_hand, dealer_hand, deck, status, wager, kind, int(is_insured)) - if (did_double_down or player_value == 21): player_stayed(from_comment) + if (did_double_down or player_value == 21) and status == 'active': + player_stayed(from_comment) def player_stayed(from_comment): player_hand, dealer_hand, deck, status, wager, kind, is_insured = from_comment.blackjack_result.split("_")