From f645fdd91eb738b1a2a07472ebe093194ea192a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20H=2E=20Fjeld?= Date: Wed, 20 Nov 2024 16:27:37 +0100 Subject: [PATCH] dev,doc: Also document migration structure --- devops/manage-statbus.sh | 6 +++--- doc/db/table/db_migration.md | 26 ++++++++++++++++++++++++++ doc/db/table/db_migration_details.md | 27 +++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 doc/db/table/db_migration.md create mode 100644 doc/db/table/db_migration_details.md diff --git a/devops/manage-statbus.sh b/devops/manage-statbus.sh index 41302eb77..209cb6ea3 100755 --- a/devops/manage-statbus.sh +++ b/devops/manage-statbus.sh @@ -597,13 +597,13 @@ EOS tables=$(./devops/manage-statbus.sh psql -t -c " SELECT schemaname || '.' || tablename FROM pg_catalog.pg_tables - WHERE schemaname IN ('admin', 'lifecycle_callbacks', 'public') + WHERE schemaname IN ('admin', 'db', 'lifecycle_callbacks', 'public') ORDER BY 1;") views=$(./devops/manage-statbus.sh psql -t -c " SELECT schemaname || '.' || viewname FROM pg_catalog.pg_views - WHERE schemaname IN ('admin', 'lifecycle_callbacks', 'public') + WHERE schemaname IN ('admin', 'db', 'lifecycle_callbacks', 'public') ORDER BY 1;") # Document each table @@ -670,7 +670,7 @@ EOS ) || ')' FROM pg_proc p JOIN pg_namespace n ON p.pronamespace = n.oid - WHERE n.nspname IN ('admin', 'lifecycle_callbacks', 'public') + WHERE n.nspname IN ('admin', 'db', 'lifecycle_callbacks', 'public') AND NOT ( (n.nspname = 'public' AND p.proname LIKE '_%') OR (n.nspname = 'public' AND p.proname LIKE '%_dist') diff --git a/doc/db/table/db_migration.md b/doc/db/table/db_migration.md new file mode 100644 index 000000000..bd8cd1e93 --- /dev/null +++ b/doc/db/table/db_migration.md @@ -0,0 +1,26 @@ +```sql + Table "db.migration" + Column | Type | Collation | Nullable | Default +-------------------+--------------------------+-----------+----------+------------------------------------------ + id | integer | | not null | nextval('db.migration_id_seq'::regclass) + major_version | text | | not null | + minor_version | text | | | + filename | text | | not null | + sha256_hash | text | | not null | + applied_at | timestamp with time zone | | not null | now() + duration_ms | integer | | not null | + major_description | text | | not null | + minor_description | text | | | +Indexes: + "migration_pkey" PRIMARY KEY, btree (id) + "migration_major_version_idx" btree (major_version) + "migration_minor_version_idx" btree (minor_version) + "migration_sha256_hash_idx" btree (sha256_hash) +Check constraints: + "major and minor consistency" CHECK (minor_version IS NULL AND minor_description IS NULL OR minor_version IS NOT NULL AND minor_description IS NOT NULL) +Policies: + POLICY "migration_authenticated_read" FOR SELECT + TO authenticated + USING (true) + +``` diff --git a/doc/db/table/db_migration_details.md b/doc/db/table/db_migration_details.md new file mode 100644 index 000000000..f70ddd35c --- /dev/null +++ b/doc/db/table/db_migration_details.md @@ -0,0 +1,27 @@ +```sql + Table "db.migration" + Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description +-------------------+--------------------------+-----------+----------+------------------------------------------+----------+-------------+--------------+------------- + id | integer | | not null | nextval('db.migration_id_seq'::regclass) | plain | | | + major_version | text | | not null | | extended | | | + minor_version | text | | | | extended | | | + filename | text | | not null | | extended | | | + sha256_hash | text | | not null | | extended | | | + applied_at | timestamp with time zone | | not null | now() | plain | | | + duration_ms | integer | | not null | | plain | | | + major_description | text | | not null | | extended | | | + minor_description | text | | | | extended | | | +Indexes: + "migration_pkey" PRIMARY KEY, btree (id) + "migration_major_version_idx" btree (major_version) + "migration_minor_version_idx" btree (minor_version) + "migration_sha256_hash_idx" btree (sha256_hash) +Check constraints: + "major and minor consistency" CHECK (minor_version IS NULL AND minor_description IS NULL OR minor_version IS NOT NULL AND minor_description IS NOT NULL) +Policies: + POLICY "migration_authenticated_read" FOR SELECT + TO authenticated + USING (true) +Access method: heap + +```