Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .renovaterc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@
"matchStrings": [
"#\\s+renovate:\\s+datasource=github-releases\\s+depName=(?<depName>\\S+)\\s+\\w+:\\s+(?<currentValue>\\S+)"
]
},
{
"autoReplaceStringTemplate": "image: {{{depName}}}:{{{newValue}}}{{#if newDigest}}@{{{newDigest}}}{{/if}}",
"customType": "regex",
"datasourceTemplate": "docker",
"description": "the docker-compose manager skips images nested below an extension key, like a dargstack platform override",
"managerFilePatterns": ["/^src/development/postgres/compose\\.yaml$/"],
"matchStrings": [
"image:\\s+(?<depName>imresamu/postgis):(?<currentValue>[^@\\s]+)(?:@(?<currentDigest>sha256:[a-f0-9]+))?"
]
}
],
"extends": ["github>dargmuesli/renovate-config"],
Expand Down
91 changes: 17 additions & 74 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,92 +1,35 @@
## [22.2.6](https://github.com/maevsi/stack/compare/22.2.5...22.2.6) (2026-11-28)

### Bug Fixes

* **deps:** update ghcr.io/maevsi/vibetype docker tag to v17.66.0 ([c33a49c](https://github.com/maevsi/stack/commit/c33a49c5ceb8cc8efba417002acf95e5b84b950e))

## [22.2.5](https://github.com/maevsi/stack/compare/22.2.4...22.2.5) (2026-11-27)

### Bug Fixes

* **deps:** update ghcr.io/maevsi/vibetype docker tag to v17.64.0 ([ce770ef](https://github.com/maevsi/stack/commit/ce770ef5bdfd2340d18a86ae5eb5c5ae1ae2a186))

## [22.2.4](https://github.com/maevsi/stack/compare/22.2.3...22.2.4) (2026-11-27)

### Bug Fixes

* **deps:** update ghcr.io/maevsi/vibetype docker tag to v17.62.0 ([4daa248](https://github.com/maevsi/stack/commit/4daa248717eab33c12e6bd8daf9b2b5904281576))

## [22.2.3](https://github.com/maevsi/stack/compare/22.2.2...22.2.3) (2026-11-27)

### Bug Fixes

* **deps:** update ghcr.io/maevsi/vibetype docker tag to v17.61.5 ([7d7836e](https://github.com/maevsi/stack/commit/7d7836e9e49c3f400f46c950f67c3919c49ed0ec))

## [22.2.2](https://github.com/maevsi/stack/compare/22.2.1...22.2.2) (2026-11-26)

### Bug Fixes

* **deps:** update maevsi images ([4f55931](https://github.com/maevsi/stack/commit/4f5593154589def22244103cd2e1087f2878f050))

## [22.2.1](https://github.com/maevsi/stack/compare/22.2.0...22.2.1) (2026-11-25)

### Bug Fixes

* **deps:** update ghcr.io/maevsi/vibetype docker tag to v17.61.2 ([fc7d8b5](https://github.com/maevsi/stack/commit/fc7d8b5f9b60f209be5fc10de004f032ffa43361))

## [22.2.0](https://github.com/maevsi/stack/compare/22.1.4...22.2.0) (2026-11-25)
## [23.0.0-beta.2](https://github.com/maevsi/stack/compare/23.0.0-beta.1...23.0.0-beta.2) (2026-11-28)

### Features

* **postgraphile:** pass the openai api key ([#369](https://github.com/maevsi/stack/issues/369)) ([adae197](https://github.com/maevsi/stack/commit/adae1976ef481c202cc64c92086a4623ad893d44))
* **zammad:** remove backup service ([#375](https://github.com/maevsi/stack/issues/375)) ([dd1ad0e](https://github.com/maevsi/stack/commit/dd1ad0ed2dacb337fc372567831d56ca49ec3aec))

## [22.1.4](https://github.com/maevsi/stack/compare/22.1.3...22.1.4) (2026-11-25)

### Bug Fixes

* **deps:** update maevsi images ([1166ab2](https://github.com/maevsi/stack/commit/1166ab2363d1f1268eb1077a20b1d8d3f787f9cb))

## [22.1.3](https://github.com/maevsi/stack/compare/22.1.2...22.1.3) (2026-11-25)

### Bug Fixes

* **compose:** forward stop signals to setup jobs ([#368](https://github.com/maevsi/stack/issues/368)) ([215cb15](https://github.com/maevsi/stack/commit/215cb15920b6aa5aeffb92b07e323b79733ad1ed))
* **deps:** update all non-major dependencies ([24c2d19](https://github.com/maevsi/stack/commit/24c2d19cd8fd5734db9038e7383b23633a77c073))
* **deps:** update all non-major dependencies ([6adc6d0](https://github.com/maevsi/stack/commit/6adc6d0f9384da5539e32ce659e698adf6571654))
* **deps:** update ghcr.io/maevsi/vibetype docker tag to v17.60.0 ([fc3b8b6](https://github.com/maevsi/stack/commit/fc3b8b6e6c62c1cdc753adff2e9f4bc2384b0c72))

## [22.1.2](https://github.com/maevsi/stack/compare/22.1.1...22.1.2) (2026-11-25)

### Bug Fixes

* **deps:** update ghcr.io/maevsi/vibetype docker tag to v17.61.2 ([fc7d8b5](https://github.com/maevsi/stack/commit/fc7d8b5f9b60f209be5fc10de004f032ffa43361))
* **deps:** update ghcr.io/maevsi/vibetype docker tag to v17.61.5 ([7d7836e](https://github.com/maevsi/stack/commit/7d7836e9e49c3f400f46c950f67c3919c49ed0ec))
* **deps:** update ghcr.io/maevsi/vibetype docker tag to v17.62.0 ([4daa248](https://github.com/maevsi/stack/commit/4daa248717eab33c12e6bd8daf9b2b5904281576))
* **deps:** update ghcr.io/maevsi/vibetype docker tag to v17.64.0 ([ce770ef](https://github.com/maevsi/stack/commit/ce770ef5bdfd2340d18a86ae5eb5c5ae1ae2a186))
* **deps:** update ghcr.io/maevsi/vibetype docker tag to v17.66.0 ([c33a49c](https://github.com/maevsi/stack/commit/c33a49c5ceb8cc8efba417002acf95e5b84b950e))
* **deps:** update maevsi images ([4f55931](https://github.com/maevsi/stack/commit/4f5593154589def22244103cd2e1087f2878f050))
* **deps:** update maevsi images ([1166ab2](https://github.com/maevsi/stack/commit/1166ab2363d1f1268eb1077a20b1d8d3f787f9cb))
* **deps:** update maevsi images ([8847fbe](https://github.com/maevsi/stack/commit/8847fbecf593d480ba91ab27cbeaf1a694684a3e))
* **images:** replace digests that no longer resolve ([#367](https://github.com/maevsi/stack/issues/367)) ([9e4b3bd](https://github.com/maevsi/stack/commit/9e4b3bd85a66bff065ead542ee2859ab486495bd))

## [22.1.1](https://github.com/maevsi/stack/compare/22.1.0...22.1.1) (2026-11-24)

### Bug Fixes
## [23.0.0-beta.1](https://github.com/maevsi/stack/compare/22.0.2...23.0.0-beta.1) (2026-11-20)

* **deps:** update all non-major dependencies ([24c2d19](https://github.com/maevsi/stack/commit/24c2d19cd8fd5734db9038e7383b23633a77c073))
### ⚠ BREAKING CHANGES

## [22.1.0](https://github.com/maevsi/stack/compare/22.0.5...22.1.0) (2026-11-22)
* **postgres:** use the vibetype image for both databases (#366)

### Features

* **postgraphile:** pass the openai api key ([#369](https://github.com/maevsi/stack/issues/369)) ([adae197](https://github.com/maevsi/stack/commit/adae1976ef481c202cc64c92086a4623ad893d44))

## [22.0.5](https://github.com/maevsi/stack/compare/22.0.4...22.0.5) (2026-11-22)

### Bug Fixes

* **compose:** forward stop signals to setup jobs ([#368](https://github.com/maevsi/stack/issues/368)) ([215cb15](https://github.com/maevsi/stack/commit/215cb15920b6aa5aeffb92b07e323b79733ad1ed))

## [22.0.4](https://github.com/maevsi/stack/compare/22.0.3...22.0.4) (2026-11-22)

### Bug Fixes

* **images:** replace digests that no longer resolve ([#367](https://github.com/maevsi/stack/issues/367)) ([9e4b3bd](https://github.com/maevsi/stack/commit/9e4b3bd85a66bff065ead542ee2859ab486495bd))

## [22.0.3](https://github.com/maevsi/stack/compare/22.0.2...22.0.3) (2026-11-21)

### Bug Fixes

* **deps:** update all non-major dependencies ([6adc6d0](https://github.com/maevsi/stack/commit/6adc6d0f9384da5539e32ce659e698adf6571654))
* **postgres:** use the vibetype image for both databases ([#366](https://github.com/maevsi/stack/issues/366)) ([2864f48](https://github.com/maevsi/stack/commit/2864f489686aff178d7a8c8888365e15e1f57a64))

## [22.0.2](https://github.com/maevsi/stack/compare/22.0.1...22.0.2) (2026-11-20)

Expand Down
142 changes: 142 additions & 0 deletions docs/sqitch-major-upgrade-14.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
-- Copies the data of the sqitch 13 schemas, renamed to `<schema>_old`, into the schemas a fresh `sqitch deploy` of sqitch 14 created.
-- For the next major, copy this file to `sqitch-major-upgrade-<major>.sql` and replace the parts marked as specific to sqitch 14; the rest is generic.
-- Only columns that exist in both generations are copied, so columns dropped by the major are left behind instead of failing the whole restore.
-- Constraints (check, not null, unique) stay enforced; triggers and foreign key checks are skipped, so tables can be filled in any order.
-- Run as the database superuser with `psql -v ON_ERROR_STOP=1`; everything happens in one transaction and is undone on any error.

BEGIN;

SET LOCAL session_replication_role = replica;

-- Specific to sqitch 14: it drops the `unlisted` event visibility, which never behaved differently from `private`.
-- sqitch 13.10.2 converted the stored rows, but events created as unlisted since then would fail the enum cast of the copy.
UPDATE vibetype_old.event SET visibility = 'private' WHERE visibility = 'unlisted';

-- Specific to sqitch 14: a contact's single `email_address` becomes the list `email_addresses`.
-- A temporary column of the new name lets the generic copy take it over, and is dropped again below, so a rollback finds the old schema unchanged.
ALTER TABLE vibetype_old.contact ADD COLUMN email_addresses TEXT[];
UPDATE vibetype_old.contact SET email_addresses = ARRAY[email_address] WHERE email_address IS NOT NULL;

DO $$
DECLARE
_table RECORD;
_columns TEXT;
_values TEXT;
_overriding TEXT;
_count BIGINT;
_left_behind TEXT;
BEGIN
FOR _table IN
SELECT n.nspname AS schema_name, c.relname AS table_name, c.oid AS table_new, to_regclass(format('%I.%I', n.nspname || '_old', c.relname)) AS table_old
FROM pg_class c
JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE n.nspname IN ('vibetype', 'vibetype_private') AND c.relkind IN ('r', 'p')
ORDER BY 1, 2
LOOP
IF _table.table_old IS NULL THEN
RAISE NOTICE '%.%: new table, nothing to copy', _table.schema_name, _table.table_name;
CONTINUE;
END IF;

SELECT
string_agg(format('%I', a_new.attname), ', ' ORDER BY a_new.attnum),
-- a differing type is mostly an enum or composite of the old schema generation, which converts through its text form
-- composites go through json instead, so attributes the major added become null rather than failing the cast
string_agg(
CASE WHEN a_new.atttypid = a_old.atttypid THEN format('%I', a_new.attname)
WHEN (SELECT typtype FROM pg_type WHERE oid = a_new.atttypid) = 'c' THEN format('json_populate_record(NULL::%s, to_json(%I))', format_type(a_new.atttypid, a_new.atttypmod), a_new.attname)
ELSE format('%I::TEXT::%s', a_new.attname, format_type(a_new.atttypid, a_new.atttypmod)) END,
', ' ORDER BY a_new.attnum
),
CASE WHEN bool_or(a_new.attidentity = 'a') THEN 'OVERRIDING SYSTEM VALUE' ELSE '' END
INTO _columns, _values, _overriding
FROM pg_attribute a_new
JOIN pg_attribute a_old ON a_old.attrelid = _table.table_old AND a_old.attname = a_new.attname AND a_old.attnum > 0 AND NOT a_old.attisdropped
WHERE a_new.attrelid = _table.table_new AND a_new.attnum > 0 AND NOT a_new.attisdropped AND a_new.attgenerated = '';

EXECUTE format('INSERT INTO %s (%s) %s SELECT %s FROM %s', _table.table_new::regclass, _columns, _overriding, _values, _table.table_old);
GET DIAGNOSTICS _count = ROW_COUNT;

SELECT string_agg(a_old.attname, ', ' ORDER BY a_old.attnum) INTO _left_behind
FROM pg_attribute a_old
WHERE a_old.attrelid = _table.table_old AND a_old.attnum > 0 AND NOT a_old.attisdropped
AND NOT EXISTS (SELECT 1 FROM pg_attribute a_new WHERE a_new.attrelid = _table.table_new AND a_new.attname = a_old.attname AND NOT a_new.attisdropped);

RAISE NOTICE '%.%: % rows%', _table.schema_name, _table.table_name, _count, CASE WHEN _left_behind IS NULL THEN '' ELSE ', left behind: ' || _left_behind END;
END LOOP;

FOR _table IN
SELECT n.nspname AS schema_name, c.relname AS table_name
FROM pg_class c
JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE n.nspname IN ('vibetype_old', 'vibetype_private_old') AND c.relkind IN ('r', 'p')
AND to_regclass(format('%I.%I', left(n.nspname, -4), c.relname)) IS NULL
LOOP
RAISE NOTICE '%.%: removed by the major, left behind', _table.schema_name, _table.table_name;
END LOOP;

-- the copy wrote explicit ids, so sequences have to continue after them
FOR _table IN
SELECT s.oid AS sequence_name, a.attrelid::regclass AS table_name, a.attname AS column_name
FROM pg_class s
JOIN pg_depend d ON d.objid = s.oid AND d.deptype IN ('a', 'i')
JOIN pg_attribute a ON a.attrelid = d.refobjid AND a.attnum = d.refobjsubid
JOIN pg_namespace n ON n.oid = s.relnamespace
WHERE s.relkind = 'S' AND n.nspname IN ('vibetype', 'vibetype_private')
LOOP
EXECUTE format('SELECT setval(%L, COALESCE((SELECT max(%I) FROM %s), 0) + 1, false)', _table.sequence_name::regclass, _table.column_name, _table.table_name);
END LOOP;
END
$$;

-- Foreign keys were not checked while copying, so rows referencing nothing would otherwise go unnoticed.
DO $$
DECLARE
_constraint RECORD;
_orphans BIGINT;
BEGIN
FOR _constraint IN
SELECT
c.conname,
c.conrelid::regclass AS table_child,
c.confrelid::regclass AS table_parent,
(SELECT string_agg(format('child.%I IS NOT NULL', a.attname), ' AND ') FROM unnest(c.conkey) AS k(attnum) JOIN pg_attribute a ON a.attrelid = c.conrelid AND a.attnum = k.attnum) AS condition_present,
(SELECT string_agg(format('parent.%I = child.%I', ap.attname, ac.attname), ' AND ') FROM unnest(c.conkey, c.confkey) AS k(attnum_child, attnum_parent) JOIN pg_attribute ac ON ac.attrelid = c.conrelid AND ac.attnum = k.attnum_child JOIN pg_attribute ap ON ap.attrelid = c.confrelid AND ap.attnum = k.attnum_parent) AS condition_match
FROM pg_constraint c
JOIN pg_namespace n ON n.oid = c.connamespace
WHERE c.contype = 'f' AND n.nspname IN ('vibetype', 'vibetype_private')
LOOP
EXECUTE format('SELECT count(*) FROM %s AS child WHERE %s AND NOT EXISTS (SELECT 1 FROM %s AS parent WHERE %s)', _constraint.table_child, _constraint.condition_present, _constraint.table_parent, _constraint.condition_match)
INTO _orphans;

IF _orphans > 0 THEN
RAISE EXCEPTION '%: % rows reference no row in %', _constraint.conname, _orphans, _constraint.table_parent;
END IF;
END LOOP;
END
$$;

ALTER TABLE vibetype_old.contact DROP COLUMN email_addresses;

-- Specific to sqitch 14: the guest counts of events count seats, each guest plus their approved companions, and `guest_count_accepted` is new.
-- Its triggers were skipped by the copy, so both counters are computed from the copied guests.
UPDATE vibetype.event e
SET (guest_count, guest_count_accepted) = (
SELECT
COALESCE(SUM(1 + g.companion_count), 0),
COALESCE(SUM(1 + g.companion_count) FILTER (WHERE COALESCE(g.feedback_override, g.feedback) = 'accepted'), 0)
FROM vibetype.guest g
WHERE g.event_id = e.id
);

-- Specific to sqitch 14: `published_at` is new, so the copy filled it with the time of the upgrade.
-- Every existing event was visible from its creation on, so that is when it counts as published.
UPDATE vibetype.event SET published_at = created_at;

-- Specific to sqitch 14: derived data is written by triggers, which the copy skipped.
-- Firing only that trigger leaves the metadata, audit and notification triggers out of it.
ALTER TABLE vibetype.event ENABLE ALWAYS TRIGGER search_vector;
UPDATE vibetype.event SET name = name;
ALTER TABLE vibetype.event ENABLE TRIGGER search_vector;

COMMIT;
5 changes: 4 additions & 1 deletion docs/sqitch-major-upgrade-rehearse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ EOF
}

docker network create "$NAME" > /dev/null
docker run -d --name "$NAME" --network "$NAME" -e POSTGRES_DB=vibetype -e POSTGRES_PASSWORD=postgres postgis/postgis:18-3.6-alpine > /dev/null
docker run -d --name "$NAME" --network "$NAME" -e POSTGRES_DB=vibetype -e POSTGRES_PASSWORD=postgres ghcr.io/maevsi/postgres:1.0.0 > /dev/null
# the image's init phase runs a temporary server on the socket only, so tcp answers once the real one is up
# A failing `docker exec` looks like a server that is not up yet, so give up after two minutes and show its error.
WAITED=0
Expand All @@ -58,6 +58,9 @@ until docker exec "$NAME" pg_isready -q -h 127.0.0.1 -U postgres -d vibetype 2>
sleep 1
done

# Majors before 14 expect PostGIS, which the `postgis/postgis` image created on initialization, so an empty database needs it before the old deploy.
psql -c 'CREATE EXTENSION IF NOT EXISTS postgis'

echo "Deploying $OLD..."
sqitch "$OLD" > /dev/null

Expand Down
13 changes: 8 additions & 5 deletions docs/sqitch-major-upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ Its plan no longer matches the change history recorded in a database deployed by
The database therefore goes through a dump, upgrade and restore cycle, and the stack release that pins the new `sqitch` major is a major release itself.

The procedure below keeps the data in the same database instead of round-tripping it through a file.
The old schemas are renamed out of the way, the new major deploys fresh schemas next to them, and `sqitch-major-upgrade-<major>.sql` copies the data across, currently [`sqitch-major-upgrade-13.sql`](sqitch-major-upgrade-13.sql).
The old schemas are renamed out of the way, the new major deploys fresh schemas next to them, and `sqitch-major-upgrade-<major>.sql` copies the data across, currently [`sqitch-major-upgrade-14.sql`](sqitch-major-upgrade-14.sql).
Its copy is generic, while the parts marked as specific to a major fix data the new rules reject and rebuild derived data, so the next major starts from a copy of the file with those parts replaced.
The copy takes only the columns both generations share, so a column the major dropped, or one that was applied by hand and never made it into a release, is reported and left behind instead of failing the restore.

## Before you start

The new stack release has to be tagged and pin the new `sqitch`, `postgraphile` and `vibetype` versions together, as the GraphQL API changes with the schema.
Production has to run the last release of the previous `sqitch` major first, as it fixes the rows that the new major's rules reject, like usernames that differ only in case before `sqitch` 14.
Never deploy that release the usual way before following this procedure: its `sqitch` fails on the old database, and the new `vibetype` then runs against the old schema.
Plan for downtime: the application is unavailable from the first step until the last.

Expand Down Expand Up @@ -82,17 +83,19 @@ psql_vibetype() {
5. Copy the data:

```sh
psql_vibetype < docs/sqitch-major-upgrade-13.sql
psql_vibetype < docs/sqitch-major-upgrade-14.sql
```

It prints one line per table with the number of rows copied and the columns left behind, and lists tables the major removed.
Everything happens in one transaction, so an error leaves the new schemas empty.
A row that violates a constraint the major introduced aborts the copy and names the table and value.
Fix that row in the `_old` schema, then run the script again.

Contacts with neither a linked account nor an email address violate the `contact_identity_check` of `sqitch` 13.
The script gives them their creator's email address with a `+vibetype` tag, like `name+vibetype@example.com`, so invitations to them reach the creator.
It writes that address into the `_old` schema too, where it stays after a rollback.
`sqitch` 14 drops the `unlisted` event visibility, so the script stores events created as unlisted since `sqitch` 13.10.2 as private, which behaves the same.
It writes that change into the `_old` schema too, where it stays after a rollback.
It also sets the new `published_at` of every existing event to the event's creation time, as all of them were visible from then on.
A contact's email address becomes the only entry of its new list of email addresses, so the copy reports `email_address` as left behind while its value moved.
The guest counts of events are computed again from the copied guests, as `sqitch` 14 counts seats and adds the count of accepted guests.

6. Deploy the full release, which scales the stopped services back up against the new schema:

Expand Down
Loading