Files
omnivore/packages/db/migrations/0083.do.webhooks.sql
2022-05-26 14:50:10 +08:00

24 lines
735 B
PL/PgSQL
Executable File

-- Type: DO
-- Name: webhooks
-- Description: webhooks model
BEGIN;
CREATE TABLE omnivore.webhooks (
id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(),
user_id uuid NOT NULL REFERENCES omnivore.user ON DELETE CASCADE,
url text NOT NULL,
method text NOT NULL DEFAULT 'POST',
content_type text NOT NULL DEFAULT 'application/json',
enabled boolean NOT NULL DEFAULT true,
event_types text[] NOT NULL,
created_at timestamptz NOT NULL DEFAULT current_timestamp,
updated_at timestamptz NOT NULL DEFAULT current_timestamp,
UNIQUE (user_id, event_types)
);
CREATE TRIGGER update_webhook_modtime BEFORE UPDATE ON omnivore.webhooks
FOR EACH ROW EXECUTE PROCEDURE update_updated_at_column();
COMMIT;