Skip to content

Commit

Permalink
dev,doc: Also document migration structure
Browse files Browse the repository at this point in the history
  • Loading branch information
jhf committed Nov 20, 2024
1 parent 92b73e4 commit f645fdd
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 3 deletions.
6 changes: 3 additions & 3 deletions devops/manage-statbus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down
26 changes: 26 additions & 0 deletions doc/db/table/db_migration.md
Original file line number Diff line number Diff line change
@@ -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)

```
27 changes: 27 additions & 0 deletions doc/db/table/db_migration_details.md
Original file line number Diff line number Diff line change
@@ -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

```

0 comments on commit f645fdd

Please sign in to comment.