Реализовать lab3 на оценку 4: балансировка и отказ API

This commit is contained in:
Daria0w0
2026-10-23 17:14:32 +03:00
parent 0ab3a341aa
commit a67e7996ec
88 changed files with 5105 additions and 21 deletions
+38
View File
@@ -0,0 +1,38 @@
\set ON_ERROR_STOP on
BEGIN;
SET LOCAL lock_timeout = '10s';
SET LOCAL statement_timeout = '30s';
-- All migration runners for this application must use this same lock key.
SELECT pg_advisory_xact_lock(2026, 2);
CREATE TABLE IF NOT EXISTS schema_migrations (
version BIGINT PRIMARY KEY,
applied_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
);
SELECT EXISTS (
SELECT 1 FROM schema_migrations WHERE version = 1
) AS initial_applied \gset
\if :initial_applied
\echo 'Migration 000001 already applied; skipping.'
\else
\ir 000001_initial.up.sql
INSERT INTO schema_migrations (version) VALUES (1);
\echo 'Migration 000001 applied (commit follows).'
\endif
SELECT EXISTS (
SELECT 1 FROM schema_migrations WHERE version = 2
) AS message_keys_applied \gset
\if :message_keys_applied
\echo 'Migration 000002 already applied; skipping.'
\else
\ir 000002_message_keys.up.sql
INSERT INTO schema_migrations (version) VALUES (2);
\endif
COMMIT;