images: add blacklisted column

This commit is contained in:
Tigor Hutasuhut 2024-08-09 08:33:23 +07:00
parent ab86ff19a5
commit 3ae3606ca1

View file

@ -16,7 +16,8 @@ CREATE TABLE images(
image_width INTEGER NOT NULL DEFAULT 0, image_width INTEGER NOT NULL DEFAULT 0,
image_size BIGINT NOT NULL DEFAULT 0, image_size BIGINT NOT NULL DEFAULT 0,
thumbnail_relative_path VARCHAR(255) NOT NULL DEFAULT '', thumbnail_relative_path VARCHAR(255) NOT NULL DEFAULT '',
nsfw INTEGER NOT NULL DEFAULT 0, nsfw TINYINT NOT NULL DEFAULT 0,
blacklisted TINYINT NOT NULL DEFAULT 0,
created_at BIGINT NOT NULL DEFAULT (strftime('%s', 'now')), created_at BIGINT NOT NULL DEFAULT (strftime('%s', 'now')),
updated_at BIGINT NOT NULL DEFAULT (strftime('%s', 'now')), updated_at BIGINT NOT NULL DEFAULT (strftime('%s', 'now')),
CONSTRAINT fk_image_subreddit CONSTRAINT fk_image_subreddit
@ -29,10 +30,11 @@ CREATE TABLE images(
ON DELETE CASCADE ON DELETE CASCADE
); );
CREATE INDEX idx_subreddit_images ON images(subreddit); CREATE INDEX idx_subreddit_images_blacklisted ON images(subreddit, blacklisted);
CREATE INDEX idx_subreddit_device_images ON images(device, subreddit); CREATE INDEX idx_subreddit_device_images_blacklisted ON images(device, subreddit, blacklisted);
CREATE INDEX idx_nsfw_images ON images(nsfw); CREATE INDEX idx_images_nsfw_blacklisted ON images(nsfw, blacklisted);
CREATE INDEX idx_images_created_at_nsfw ON images(created_at DESC, nsfw); CREATE INDEX idx_images_created_at_nsfw_blacklisted ON images(created_at DESC, nsfw, blacklisted);
CREATE INDEX idx_images_blacklisted ON images(blacklisted);
CREATE UNIQUE INDEX idx_unique_images_per_device ON images(device, post_name); CREATE UNIQUE INDEX idx_unique_images_per_device ON images(device, post_name);
-- +goose StatementEnd -- +goose StatementEnd