2024-04-07 00:28:29 +07:00
|
|
|
-- +goose Up
|
|
|
|
-- +goose StatementBegin
|
|
|
|
CREATE TABLE subreddits (
|
|
|
|
id INTEGER PRIMARY KEY,
|
|
|
|
name VARCHAR(30) NOT NULL,
|
2024-04-09 23:07:36 +07:00
|
|
|
enable INT NOT NULL DEFAULT 1,
|
2024-04-09 22:37:26 +07:00
|
|
|
subtype INT NOT NULL DEFAULT 0,
|
|
|
|
schedule VARCHAR(20) NOT NULL DEFAULT '0 0 * * *',
|
|
|
|
countback INT NOT NULL DEFAULT 100,
|
2024-04-07 00:28:29 +07:00
|
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
|
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL
|
|
|
|
);
|
2024-04-09 21:49:23 +07:00
|
|
|
|
|
|
|
CREATE UNIQUE INDEX idx_subreddits_name ON subreddits (name);
|
|
|
|
|
|
|
|
CREATE TRIGGER update_subreddits_timestamp AFTER UPDATE ON subreddits FOR EACH ROW
|
|
|
|
BEGIN
|
|
|
|
UPDATE subreddits SET updated_at = CURRENT_TIMESTAMP WHERE id = old.id;
|
|
|
|
END;
|
2024-04-07 00:28:29 +07:00
|
|
|
-- +goose StatementEnd
|
|
|
|
|
|
|
|
-- +goose Down
|
|
|
|
-- +goose StatementBegin
|
|
|
|
DROP TABLE subreddits;
|
|
|
|
-- +goose StatementEnd
|