Реализовать наблюдаемость и доказательства уровня 4
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
spring:
|
||||
application:
|
||||
name: mtusi-messenger
|
||||
|
||||
datasource:
|
||||
url: ${DATABASE_URL:jdbc:postgresql://localhost:5432/messenger}
|
||||
username: ${DATABASE_USER:messenger}
|
||||
password: ${DATABASE_PASSWORD:messenger}
|
||||
hikari:
|
||||
maximum-pool-size: ${DATABASE_POOL_SIZE:10}
|
||||
minimum-idle: ${DATABASE_MIN_IDLE:2}
|
||||
connection-timeout: 5000
|
||||
validation-timeout: 2000
|
||||
idle-timeout: 600000
|
||||
max-lifetime: 1800000
|
||||
|
||||
data:
|
||||
redis:
|
||||
host: ${REDIS_HOST:localhost}
|
||||
port: ${REDIS_PORT:6379}
|
||||
connect-timeout: ${REDIS_CONNECT_TIMEOUT:1s}
|
||||
timeout: ${REDIS_COMMAND_TIMEOUT:500ms}
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: ${REDIS_POOL_MAX_ACTIVE:8}
|
||||
max-idle: ${REDIS_POOL_MAX_IDLE:8}
|
||||
min-idle: ${REDIS_POOL_MIN_IDLE:0}
|
||||
max-wait: ${REDIS_POOL_MAX_WAIT:500ms}
|
||||
|
||||
rabbitmq:
|
||||
host: ${RABBITMQ_HOST:localhost}
|
||||
port: ${RABBITMQ_PORT:5672}
|
||||
username: ${RABBITMQ_USER:messenger}
|
||||
password: ${RABBITMQ_PASSWORD:messenger}
|
||||
virtual-host: ${RABBITMQ_VHOST:/}
|
||||
connection-timeout: ${RABBITMQ_CONNECTION_TIMEOUT:5s}
|
||||
publisher-confirm-type: correlated
|
||||
publisher-returns: true
|
||||
listener:
|
||||
simple:
|
||||
acknowledge-mode: manual
|
||||
default-requeue-rejected: false
|
||||
prefetch: ${WORKER_PREFETCH:1}
|
||||
concurrency: ${WORKER_CONCURRENCY:2}
|
||||
max-concurrency: ${WORKER_CONCURRENCY:2}
|
||||
|
||||
jdbc:
|
||||
template:
|
||||
query-timeout: ${DATABASE_QUERY_TIMEOUT_SECONDS:5}
|
||||
|
||||
transaction:
|
||||
default-timeout: ${DATABASE_TRANSACTION_TIMEOUT_SECONDS:5}
|
||||
|
||||
flyway:
|
||||
# API replicas never race one another for migrations. Compose runs the
|
||||
# same image once as the dedicated migrate service with this overridden.
|
||||
enabled: ${FLYWAY_ENABLED:false}
|
||||
locations: classpath:db/migration
|
||||
|
||||
jackson:
|
||||
deserialization:
|
||||
fail-on-unknown-properties: true
|
||||
|
||||
lifecycle:
|
||||
timeout-per-shutdown-phase: 10s
|
||||
|
||||
server:
|
||||
address: ${APP_HOST:0.0.0.0}
|
||||
port: ${APP_PORT:8080}
|
||||
shutdown: graceful
|
||||
|
||||
# Spring Boot writes one JSON object per line. The OTel agent injects trace_id
|
||||
# and span_id into MDC and exports the same records through OTLP. Request and
|
||||
# message bodies, credentials and signed URLs are never configured for capture.
|
||||
logging:
|
||||
structured:
|
||||
format:
|
||||
console: logstash
|
||||
|
||||
messenger:
|
||||
role: ${MESSENGER_ROLE:api}
|
||||
storage: postgres
|
||||
session:
|
||||
ttl-seconds: ${SESSION_TTL_SECONDS:3600}
|
||||
cache:
|
||||
user-ttl-seconds: ${USER_CACHE_TTL_SECONDS:300}
|
||||
idempotency:
|
||||
ttl-seconds: ${IDEMPOTENCY_TTL_SECONDS:86400}
|
||||
s3:
|
||||
endpoint: ${S3_ENDPOINT:http://localhost:9000}
|
||||
region: ${S3_REGION:us-east-1}
|
||||
bucket: ${S3_BUCKET:messenger-attachments}
|
||||
access-key: ${S3_ACCESS_KEY_ID:messenger-api}
|
||||
secret-key: ${S3_SECRET_ACCESS_KEY:messenger-api-local-only}
|
||||
attachments:
|
||||
max-upload-bytes: ${MAX_UPLOAD_BYTES:10485760}
|
||||
max-image-pixels: ${MAX_IMAGE_PIXELS:40000000}
|
||||
max-concurrent-uploads: ${MAX_CONCURRENT_UPLOADS:3}
|
||||
upload-permit-wait-millis: ${UPLOAD_PERMIT_WAIT_MILLIS:10000}
|
||||
staging-retention-seconds: ${STAGING_RETENTION_SECONDS:86400}
|
||||
cleanup-grace-seconds: ${ATTACHMENT_CLEANUP_GRACE_SECONDS:3600}
|
||||
cleanup-dry-run: ${ATTACHMENT_CLEANUP_DRY_RUN:false}
|
||||
reconcile-interval-millis: ${ATTACHMENT_RECONCILE_INTERVAL_MILLIS:600000}
|
||||
reconcile-initial-delay-millis: ${ATTACHMENT_RECONCILE_INITIAL_DELAY_MILLIS:60000}
|
||||
jobs:
|
||||
pipeline-version: ${ATTACHMENT_PIPELINE_VERSION:2}
|
||||
exchange: ${ATTACHMENT_JOB_EXCHANGE:attachments.v1}
|
||||
queue: ${ATTACHMENT_JOB_QUEUE:attachments.process.level4.v1}
|
||||
routing-key: ${ATTACHMENT_JOB_ROUTING_KEY:attachment.process.v1}
|
||||
dead-letter-exchange: ${ATTACHMENT_DLQ_EXCHANGE:attachments.dlx.v1}
|
||||
dead-letter-queue: ${ATTACHMENT_DLQ_QUEUE:attachments.failed.v1}
|
||||
dead-letter-routing-key: ${ATTACHMENT_DLQ_ROUTING_KEY:attachment.failed.v1}
|
||||
max-attempts: ${JOB_MAX_ATTEMPTS:5}
|
||||
retry-base-delay: ${JOB_RETRY_BASE_DELAY:1s}
|
||||
retry-max-delay: ${JOB_RETRY_MAX_DELAY:30s}
|
||||
timeout: ${JOB_TIMEOUT:60s}
|
||||
lease-duration: ${JOB_LEASE_DURATION:90s}
|
||||
lease-reaper-interval: ${JOB_LEASE_REAPER_INTERVAL:5s}
|
||||
worker-max-pixels: ${WORKER_MAX_IMAGE_PIXELS:40000000}
|
||||
worker-memory-budget-bytes: ${WORKER_MEMORY_BUDGET_BYTES:536870912}
|
||||
memory-wait: ${WORKER_MEMORY_WAIT:2s}
|
||||
publish-confirm-timeout: ${JOB_PUBLISH_CONFIRM_TIMEOUT:5s}
|
||||
republish-interval: ${JOB_REPUBLISH_INTERVAL:5s}
|
||||
fault-crash-after-outbox-commit: ${FAULT_CRASH_AFTER_OUTBOX_COMMIT:false}
|
||||
fault-crash-before-side-effect: ${FAULT_CRASH_BEFORE_SIDE_EFFECT:false}
|
||||
fault-crash-after-side-effect: ${FAULT_CRASH_AFTER_SIDE_EFFECT:false}
|
||||
fault-crash-after-result-commit: ${FAULT_CRASH_AFTER_RESULT_COMMIT:false}
|
||||
observability:
|
||||
queue-poll-interval: ${OBSERVABILITY_QUEUE_POLL_INTERVAL:5s}
|
||||
@@ -0,0 +1,60 @@
|
||||
CREATE TABLE users (
|
||||
id uuid PRIMARY KEY,
|
||||
username varchar(32) NOT NULL,
|
||||
display_name text NOT NULL,
|
||||
created_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT users_username_uk UNIQUE (username),
|
||||
CONSTRAINT users_username_format_chk
|
||||
CHECK (username ~ '^[a-z0-9_]{3,32}$'),
|
||||
CONSTRAINT users_display_name_length_chk
|
||||
CHECK (char_length(display_name) BETWEEN 1 AND 100)
|
||||
);
|
||||
|
||||
CREATE TABLE chats (
|
||||
id uuid PRIMARY KEY,
|
||||
title text NOT NULL,
|
||||
created_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT chats_title_length_chk
|
||||
CHECK (char_length(title) BETWEEN 1 AND 100)
|
||||
);
|
||||
|
||||
CREATE TABLE chat_members (
|
||||
chat_id uuid NOT NULL,
|
||||
user_id uuid NOT NULL,
|
||||
joined_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT chat_members_pk PRIMARY KEY (chat_id, user_id),
|
||||
CONSTRAINT chat_members_chat_fk
|
||||
FOREIGN KEY (chat_id) REFERENCES chats(id) ON DELETE CASCADE,
|
||||
CONSTRAINT chat_members_user_fk
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE RESTRICT
|
||||
);
|
||||
|
||||
CREATE TABLE messages (
|
||||
id uuid PRIMARY KEY,
|
||||
chat_id uuid NOT NULL,
|
||||
sender_id uuid NOT NULL,
|
||||
text text NOT NULL,
|
||||
created_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT messages_text_length_chk
|
||||
CHECK (char_length(text) BETWEEN 1 AND 4000),
|
||||
CONSTRAINT messages_sender_membership_fk
|
||||
FOREIGN KEY (chat_id, sender_id)
|
||||
REFERENCES chat_members(chat_id, user_id)
|
||||
ON DELETE RESTRICT
|
||||
);
|
||||
|
||||
CREATE INDEX chat_members_user_chat_idx
|
||||
ON chat_members (user_id, chat_id);
|
||||
|
||||
CREATE INDEX chats_created_id_idx
|
||||
ON chats (created_at, id);
|
||||
|
||||
CREATE INDEX messages_chat_created_id_idx
|
||||
ON messages (chat_id, created_at, id);
|
||||
|
||||
CREATE INDEX messages_sender_created_idx
|
||||
ON messages (sender_id, created_at);
|
||||
@@ -0,0 +1,28 @@
|
||||
ALTER TABLE users
|
||||
ADD COLUMN password_hash text;
|
||||
|
||||
ALTER TABLE users
|
||||
ALTER COLUMN password_hash SET NOT NULL;
|
||||
|
||||
CREATE TABLE sessions (
|
||||
id uuid PRIMARY KEY,
|
||||
user_id uuid NOT NULL,
|
||||
token_hash bytea NOT NULL,
|
||||
created_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
expires_at timestamptz NOT NULL,
|
||||
revoked_at timestamptz,
|
||||
|
||||
CONSTRAINT sessions_user_fk
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
CONSTRAINT sessions_token_hash_uk UNIQUE (token_hash),
|
||||
CONSTRAINT sessions_token_hash_length_chk
|
||||
CHECK (octet_length(token_hash) = 32),
|
||||
CONSTRAINT sessions_expiry_chk
|
||||
CHECK (expires_at > created_at),
|
||||
CONSTRAINT sessions_revocation_chk
|
||||
CHECK (revoked_at IS NULL OR revoked_at >= created_at)
|
||||
);
|
||||
|
||||
CREATE INDEX sessions_active_expiry_idx
|
||||
ON sessions (expires_at)
|
||||
WHERE revoked_at IS NULL;
|
||||
@@ -0,0 +1,25 @@
|
||||
CREATE TABLE message_idempotency (
|
||||
user_id uuid NOT NULL,
|
||||
method varchar(8) NOT NULL,
|
||||
request_path text NOT NULL,
|
||||
idempotency_key varchar(128) NOT NULL,
|
||||
request_hash bytea NOT NULL,
|
||||
message_id uuid NOT NULL,
|
||||
created_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT message_idempotency_pk
|
||||
PRIMARY KEY (user_id, method, request_path, idempotency_key),
|
||||
CONSTRAINT message_idempotency_user_fk
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
CONSTRAINT message_idempotency_message_fk
|
||||
FOREIGN KEY (message_id) REFERENCES messages(id) ON DELETE CASCADE,
|
||||
CONSTRAINT message_idempotency_method_chk
|
||||
CHECK (method = 'POST'),
|
||||
CONSTRAINT message_idempotency_key_format_chk
|
||||
CHECK (idempotency_key ~ '^[A-Za-z0-9._:-]{1,128}$'),
|
||||
CONSTRAINT message_idempotency_hash_length_chk
|
||||
CHECK (octet_length(request_hash) = 32)
|
||||
);
|
||||
|
||||
CREATE INDEX message_idempotency_created_idx
|
||||
ON message_idempotency (created_at);
|
||||
@@ -0,0 +1,53 @@
|
||||
ALTER TABLE messages DROP CONSTRAINT messages_text_length_chk;
|
||||
ALTER TABLE messages ADD CONSTRAINT messages_text_length_chk
|
||||
CHECK (char_length(text) BETWEEN 0 AND 4000);
|
||||
ALTER TABLE messages ADD CONSTRAINT messages_id_chat_uk UNIQUE (id, chat_id);
|
||||
|
||||
CREATE TABLE attachments (
|
||||
id uuid PRIMARY KEY,
|
||||
chat_id uuid NOT NULL,
|
||||
owner_id uuid NOT NULL,
|
||||
filename varchar(255) NOT NULL,
|
||||
content_type varchar(32) NOT NULL,
|
||||
size_bytes bigint NOT NULL,
|
||||
sha256 char(64) NOT NULL,
|
||||
object_key text NOT NULL,
|
||||
status varchar(16) NOT NULL DEFAULT 'ready',
|
||||
created_at timestamptz NOT NULL,
|
||||
updated_at timestamptz NOT NULL,
|
||||
|
||||
CONSTRAINT attachments_id_chat_uk UNIQUE (id, chat_id),
|
||||
CONSTRAINT attachments_object_key_uk UNIQUE (object_key),
|
||||
CONSTRAINT attachments_owner_membership_fk
|
||||
FOREIGN KEY (chat_id, owner_id)
|
||||
REFERENCES chat_members(chat_id, user_id) ON DELETE RESTRICT,
|
||||
CONSTRAINT attachments_content_type_chk
|
||||
CHECK (content_type IN ('image/png', 'image/jpeg')),
|
||||
CONSTRAINT attachments_size_chk
|
||||
CHECK (size_bytes BETWEEN 1 AND 10485760),
|
||||
CONSTRAINT attachments_sha256_chk
|
||||
CHECK (sha256 ~ '^[a-f0-9]{64}$'),
|
||||
CONSTRAINT attachments_status_chk CHECK (status = 'ready'),
|
||||
CONSTRAINT attachments_filename_chk
|
||||
CHECK (char_length(filename) BETWEEN 1 AND 255)
|
||||
);
|
||||
|
||||
CREATE TABLE message_attachments (
|
||||
message_id uuid NOT NULL,
|
||||
chat_id uuid NOT NULL,
|
||||
attachment_id uuid NOT NULL,
|
||||
position smallint NOT NULL,
|
||||
|
||||
CONSTRAINT message_attachments_pk PRIMARY KEY (message_id, attachment_id),
|
||||
CONSTRAINT message_attachments_position_uk UNIQUE (message_id, position),
|
||||
CONSTRAINT message_attachments_message_fk
|
||||
FOREIGN KEY (message_id, chat_id)
|
||||
REFERENCES messages(id, chat_id) ON DELETE CASCADE,
|
||||
CONSTRAINT message_attachments_attachment_fk
|
||||
FOREIGN KEY (attachment_id, chat_id)
|
||||
REFERENCES attachments(id, chat_id) ON DELETE RESTRICT,
|
||||
CONSTRAINT message_attachments_position_chk CHECK (position BETWEEN 0 AND 9)
|
||||
);
|
||||
|
||||
CREATE INDEX attachments_chat_created_idx ON attachments (chat_id, created_at, id);
|
||||
CREATE INDEX message_attachments_attachment_idx ON message_attachments (attachment_id);
|
||||
@@ -0,0 +1,57 @@
|
||||
ALTER TABLE attachments DROP CONSTRAINT attachments_status_chk;
|
||||
ALTER TABLE attachments
|
||||
ADD COLUMN staging_key text,
|
||||
ADD COLUMN error_code varchar(64),
|
||||
ADD CONSTRAINT attachments_status_chk
|
||||
CHECK (status IN ('queued', 'processing', 'ready', 'failed')),
|
||||
ADD CONSTRAINT attachments_error_state_chk
|
||||
CHECK ((status = 'failed' AND error_code IS NOT NULL)
|
||||
OR (status <> 'failed' AND error_code IS NULL));
|
||||
|
||||
CREATE UNIQUE INDEX attachments_staging_key_uk
|
||||
ON attachments (staging_key) WHERE staging_key IS NOT NULL;
|
||||
|
||||
CREATE TABLE attachment_variants (
|
||||
attachment_id uuid NOT NULL REFERENCES attachments(id) ON DELETE CASCADE,
|
||||
pipeline_version integer NOT NULL,
|
||||
name varchar(32) NOT NULL,
|
||||
content_type varchar(32) NOT NULL,
|
||||
size_bytes bigint NOT NULL,
|
||||
width integer NOT NULL,
|
||||
height integer NOT NULL,
|
||||
sha256 char(64) NOT NULL,
|
||||
object_key text NOT NULL,
|
||||
created_at timestamptz NOT NULL,
|
||||
|
||||
CONSTRAINT attachment_variants_pk
|
||||
PRIMARY KEY (attachment_id, pipeline_version, name),
|
||||
CONSTRAINT attachment_variants_object_key_uk UNIQUE (object_key),
|
||||
CONSTRAINT attachment_variants_name_chk
|
||||
CHECK (name IN ('thumbnail', 'crop', 'optimized')),
|
||||
CONSTRAINT attachment_variants_content_type_chk
|
||||
CHECK (content_type IN ('image/jpeg', 'image/png', 'image/webp')),
|
||||
CONSTRAINT attachment_variants_size_chk CHECK (size_bytes > 0),
|
||||
CONSTRAINT attachment_variants_dimensions_chk CHECK (width > 0 AND height > 0),
|
||||
CONSTRAINT attachment_variants_sha256_chk CHECK (sha256 ~ '^[a-f0-9]{64}$')
|
||||
);
|
||||
|
||||
CREATE TABLE attachment_jobs (
|
||||
id uuid PRIMARY KEY,
|
||||
attachment_id uuid NOT NULL UNIQUE REFERENCES attachments(id) ON DELETE CASCADE,
|
||||
pipeline_version integer NOT NULL DEFAULT 1,
|
||||
attempt integer NOT NULL DEFAULT 1,
|
||||
status varchar(16) NOT NULL DEFAULT 'queued',
|
||||
published boolean NOT NULL DEFAULT false,
|
||||
last_error_code varchar(64),
|
||||
created_at timestamptz NOT NULL,
|
||||
updated_at timestamptz NOT NULL,
|
||||
|
||||
CONSTRAINT attachment_jobs_pipeline_chk CHECK (pipeline_version > 0),
|
||||
CONSTRAINT attachment_jobs_attempt_chk CHECK (attempt > 0),
|
||||
CONSTRAINT attachment_jobs_status_chk
|
||||
CHECK (status IN ('queued', 'processing', 'ready', 'failed'))
|
||||
);
|
||||
|
||||
CREATE INDEX attachment_jobs_publish_idx
|
||||
ON attachment_jobs (published, status, created_at)
|
||||
WHERE published = false AND status = 'queued';
|
||||
@@ -0,0 +1,41 @@
|
||||
ALTER TABLE attachment_jobs
|
||||
ADD COLUMN next_attempt_at timestamptz,
|
||||
ADD COLUMN lease_token uuid,
|
||||
ADD COLUMN lease_until timestamptz,
|
||||
ADD COLUMN publish_fault_injected boolean NOT NULL DEFAULT false,
|
||||
ADD COLUMN result_fault_injected boolean NOT NULL DEFAULT false;
|
||||
|
||||
UPDATE attachment_jobs SET next_attempt_at = created_at WHERE next_attempt_at IS NULL;
|
||||
UPDATE attachment_jobs
|
||||
SET status = 'queued', published = false, last_error_code = 'lease_migration_recovery'
|
||||
WHERE status = 'processing';
|
||||
UPDATE attachments SET status = 'queued', error_code = NULL WHERE status = 'processing';
|
||||
ALTER TABLE attachment_jobs ALTER COLUMN next_attempt_at SET NOT NULL;
|
||||
ALTER TABLE attachment_jobs ALTER COLUMN next_attempt_at SET DEFAULT clock_timestamp();
|
||||
|
||||
ALTER TABLE attachment_jobs
|
||||
ADD CONSTRAINT attachment_jobs_lease_chk CHECK (
|
||||
(status = 'processing' AND lease_token IS NOT NULL AND lease_until IS NOT NULL)
|
||||
OR (status <> 'processing' AND lease_token IS NULL AND lease_until IS NULL)
|
||||
);
|
||||
|
||||
DROP INDEX attachment_jobs_publish_idx;
|
||||
CREATE INDEX attachment_jobs_publish_idx
|
||||
ON attachment_jobs (next_attempt_at, created_at, id)
|
||||
WHERE published = false AND status = 'queued';
|
||||
CREATE INDEX attachment_jobs_expired_lease_idx
|
||||
ON attachment_jobs (lease_until)
|
||||
WHERE status = 'processing';
|
||||
|
||||
CREATE TABLE attachment_job_replays (
|
||||
id bigserial PRIMARY KEY,
|
||||
job_id uuid NOT NULL REFERENCES attachment_jobs(id) ON DELETE RESTRICT,
|
||||
requested_by varchar(128) NOT NULL,
|
||||
previous_attempt integer NOT NULL,
|
||||
requested_at timestamptz NOT NULL DEFAULT clock_timestamp(),
|
||||
CONSTRAINT attachment_job_replays_actor_chk
|
||||
CHECK (char_length(requested_by) BETWEEN 1 AND 128)
|
||||
);
|
||||
|
||||
CREATE INDEX attachment_job_replays_job_idx
|
||||
ON attachment_job_replays (job_id, requested_at);
|
||||
@@ -0,0 +1,33 @@
|
||||
ALTER TABLE attachments
|
||||
ADD COLUMN pipeline_version integer NOT NULL DEFAULT 1,
|
||||
ADD CONSTRAINT attachments_pipeline_version_chk CHECK (pipeline_version > 0);
|
||||
|
||||
ALTER TABLE attachment_jobs
|
||||
DROP CONSTRAINT attachment_jobs_attachment_id_key,
|
||||
DROP CONSTRAINT attachment_jobs_status_chk,
|
||||
ADD COLUMN before_effect_fault_injected boolean NOT NULL DEFAULT false,
|
||||
ADD COLUMN after_effect_fault_injected boolean NOT NULL DEFAULT false,
|
||||
ADD CONSTRAINT attachment_jobs_status_chk
|
||||
CHECK (status IN ('queued', 'processing', 'ready', 'failed', 'superseded'));
|
||||
|
||||
CREATE UNIQUE INDEX attachment_jobs_attachment_pipeline_uk
|
||||
ON attachment_jobs (attachment_id, pipeline_version);
|
||||
|
||||
CREATE TABLE attachment_pipeline_promotions (
|
||||
id bigserial PRIMARY KEY,
|
||||
attachment_id uuid NOT NULL REFERENCES attachments(id) ON DELETE RESTRICT,
|
||||
from_version integer NOT NULL,
|
||||
to_version integer NOT NULL,
|
||||
job_id uuid NOT NULL REFERENCES attachment_jobs(id) ON DELETE RESTRICT,
|
||||
requested_by varchar(128) NOT NULL,
|
||||
requested_at timestamptz NOT NULL DEFAULT clock_timestamp(),
|
||||
CONSTRAINT attachment_pipeline_promotions_versions_chk
|
||||
CHECK (from_version > 0 AND to_version > from_version),
|
||||
CONSTRAINT attachment_pipeline_promotions_actor_chk
|
||||
CHECK (char_length(requested_by) BETWEEN 1 AND 128),
|
||||
CONSTRAINT attachment_pipeline_promotions_target_uk
|
||||
UNIQUE (attachment_id, to_version)
|
||||
);
|
||||
|
||||
CREATE INDEX attachment_pipeline_promotions_attachment_idx
|
||||
ON attachment_pipeline_promotions (attachment_id, requested_at);
|
||||
@@ -0,0 +1,12 @@
|
||||
ALTER TABLE attachment_jobs
|
||||
ADD COLUMN trace_parent varchar(55),
|
||||
ADD COLUMN trace_state text,
|
||||
ADD CONSTRAINT attachment_jobs_trace_parent_chk CHECK (
|
||||
trace_parent IS NULL
|
||||
OR trace_parent ~ '^[0-9a-f]{2}-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$'
|
||||
);
|
||||
|
||||
COMMENT ON COLUMN attachment_jobs.trace_parent IS
|
||||
'W3C traceparent used only to continue a durable retry trace';
|
||||
COMMENT ON COLUMN attachment_jobs.trace_state IS
|
||||
'W3C tracestate used only to continue a durable retry trace';
|
||||
Reference in New Issue
Block a user