ЛР 6 — БПИ2302 — Нурлыгаянова — на 3

This commit is contained in:
Nurlygayanova Ekaterina
2026-11-13 11:32:45 +03:00
parent 470d9d6f1e
commit 69a190be0e
164 changed files with 25947 additions and 29 deletions
+24
View File
@@ -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;