lemmy/migrations/2023-02-11-173347_custom_emojis/up.sql
Dessalines be1389420b
Adding SQL format checking via pg_format / pgFormatter (#3740)
* SQL format checking, 1.

* SQL format checking, 2.

* SQL format checking, 3.

* SQL format checking, 4.

* SQL format checking, 5.

* Running pg_format

* Getting rid of comment.

* Upping pg_format version.

* Using git ls-files for sql format check.

* Fixing sql lints.

* Addressing PR comments.
2023-08-02 12:44:51 -04:00

21 lines
697 B
SQL

CREATE TABLE custom_emoji (
id serial PRIMARY KEY,
local_site_id int REFERENCES local_site ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
shortcode varchar(128) NOT NULL UNIQUE,
image_url text NOT NULL UNIQUE,
alt_text text NOT NULL,
category text NOT NULL,
published timestamp without time zone DEFAULT now() NOT NULL,
updated timestamp without time zone
);
CREATE TABLE custom_emoji_keyword (
id serial PRIMARY KEY,
custom_emoji_id int REFERENCES custom_emoji ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
keyword varchar(128) NOT NULL,
UNIQUE (custom_emoji_id, keyword)
);
CREATE INDEX idx_custom_emoji_category ON custom_emoji (id, category);