forked from mtusi2026/mtusi2026lab6
ЛР 6 — БПИ2302 — Нурлыгаянова — на 3
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE attachment_jobs ADD COLUMN traceparent text NOT NULL DEFAULT '';
|
||||
ALTER TABLE attachment_jobs ADD COLUMN tracestate text NOT NULL DEFAULT '';
|
||||
-- +goose StatementBegin
|
||||
CREATE OR REPLACE FUNCTION enqueue_attachment() RETURNS trigger LANGUAGE plpgsql AS $$
|
||||
BEGIN
|
||||
IF NEW.status='queued' THEN
|
||||
INSERT INTO attachment_jobs(attachment_id, staging_key, traceparent, tracestate)
|
||||
VALUES (NEW.id, NEW.object_key, coalesce(current_setting('messenger.traceparent',true),''), coalesce(current_setting('messenger.tracestate',true),''));
|
||||
END IF;
|
||||
RETURN NEW;
|
||||
END $$;
|
||||
-- +goose StatementEnd
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
CREATE OR REPLACE FUNCTION enqueue_attachment() RETURNS trigger LANGUAGE plpgsql AS $$
|
||||
BEGIN
|
||||
IF NEW.status='queued' THEN
|
||||
INSERT INTO attachment_jobs(attachment_id, staging_key) VALUES (NEW.id, NEW.object_key);
|
||||
END IF;
|
||||
RETURN NEW;
|
||||
END $$;
|
||||
-- +goose StatementEnd
|
||||
ALTER TABLE attachment_jobs DROP COLUMN traceparent, DROP COLUMN tracestate;
|
||||
Reference in New Issue
Block a user