--up
CREATE TABLE sendgrid_sync_jobs (
    id integer GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    "job_id" varchar(255) NOT NULL,
    "trigger_script" varchar(255) NOT NULL,
    "status" varchar(255) NOT NULL,
    "response" jsonb,
    "created_at" timestamp NOT NULL DEFAULT NOW(),
    "updated_at" timestamp NOT NULL DEFAULT NOW()
);

COMMENT ON COLUMN sendgrid_sync_jobs.job_id IS 'Job ID from SendGrid';
COMMENT ON COLUMN sendgrid_sync_jobs.trigger_script IS 'Script that triggered the job';
COMMENT ON COLUMN sendgrid_sync_jobs.status IS 'Status of the job from SendGrid';
COMMENT ON COLUMN sendgrid_sync_jobs.response IS 'Whole response from SendGrid';

CREATE TRIGGER set_timestamp
BEFORE UPDATE ON sendgrid_sync_jobs FOR EACH ROW
EXECUTE PROCEDURE update_updated_at_column();

--down
DROP TRIGGER set_timestamp ON sendgrid_sync_jobs;
DROP TABLE sendgrid_sync_jobs;
