bans: change expires_at field to duration.

Changes:

* Change the `expires_at` field to `duration`.
* Make moderators choose from a fixed set of standard ban lengths,
  instead of allowing arbitrary ban lengths.
* List `duration` in seconds in the /bans.json API.
* Dump bans to BigQuery.

Note that some old bans have a negative duration. This is because their
expiration date was before their creation date, which is because in 2013
bans were migrated to Danbooru 2 and the original ban creation dates
were lost.
This commit is contained in:
evazion
2021-03-10 17:20:52 -06:00
parent 791b8c61f6
commit 81fe68d392
16 changed files with 90 additions and 86 deletions

View File

@@ -690,7 +690,7 @@ CREATE TABLE public.bans (
user_id integer,
reason text NOT NULL,
banner_id integer NOT NULL,
expires_at timestamp without time zone NOT NULL,
expires_at interval NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
@@ -5066,10 +5066,10 @@ CREATE INDEX index_bans_on_banner_id ON public.bans USING btree (banner_id);
--
-- Name: index_bans_on_expires_at; Type: INDEX; Schema: public; Owner: -
-- Name: index_bans_on_duration; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_bans_on_expires_at ON public.bans USING btree (expires_at);
CREATE INDEX index_bans_on_duration ON public.bans USING btree (duration);
--
@@ -8004,6 +8004,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20210127012303'),
('20210214095121'),
('20210214101614'),
('20210303195217');
('20210303195217'),
('20210310221248');