@axiumine/qpanel-db-setup 0.0.0-stage → 0.9.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +164 -0
- package/LICENSE +661 -0
- package/README.md +289 -2
- package/dist/migrations/20261127000000-create-enums-and-set-updated-at.mjs +25 -0
- package/dist/migrations/20261127000100-revoke-app-access-to-migration-tables.mjs +39 -0
- package/dist/migrations/20261127000200-create-admin.mjs +24 -0
- package/dist/migrations/20261127000300-create-secret.mjs +37 -0
- package/dist/migrations/20261127000400-create-audit-event.mjs +35 -0
- package/dist/migrations/20261127000500-create-registrar.mjs +27 -0
- package/dist/migrations/20261127000600-create-client.mjs +47 -0
- package/dist/migrations/20261127000700-create-client-note.mjs +22 -0
- package/dist/migrations/20261127000800-create-domain.mjs +37 -0
- package/dist/migrations/20261127000900-create-subdomain.mjs +24 -0
- package/dist/migrations/20261127001000-create-service.mjs +25 -0
- package/dist/migrations/20261127001100-create-datacenter.mjs +22 -0
- package/dist/migrations/20261127001200-create-db-instance.mjs +30 -0
- package/dist/migrations/20261127001300-create-db-instance-node.mjs +30 -0
- package/dist/migrations/20261127001400-create-db-account.mjs +34 -0
- package/dist/migrations/20261127001500-create-app-database.mjs +23 -0
- package/dist/migrations/20261127001600-create-app-database-user.mjs +31 -0
- package/dist/migrations/20261127001700-create-subdomain-app-database.mjs +25 -0
- package/dist/migrations/20261127001800-billing-fields.mjs +52 -0
- package/dist/migrations/20261128000000-secret-value-changed-at.mjs +25 -0
- package/dist/migrations/20261130000000-db-instance-environments.mjs +56 -0
- package/dist/migrations/20261130120000-create-server.mjs +50 -0
- package/dist/migrations/20261130200000-create-server-ssh-access.mjs +147 -0
- package/dist/migrations/20261201000000-ssh-login-per-way.mjs +129 -0
- package/dist/src/arguments.mjs +124 -0
- package/dist/src/bin.mjs +26 -0
- package/dist/src/cli.mjs +139 -0
- package/dist/src/create.mjs +40 -0
- package/dist/src/database.mjs +41 -0
- package/dist/src/env.mjs +49 -0
- package/dist/src/infisical.mjs +37 -0
- package/dist/src/keygrip.mjs +48 -0
- package/dist/src/masterKey.mjs +80 -0
- package/dist/src/masterKeyFile.mjs +66 -0
- package/dist/src/migrator.mjs +64 -0
- package/dist/src/redis.mjs +23 -0
- package/dist/src/secrets.mjs +96 -0
- package/dist/src/target.mjs +22 -0
- package/package.json +83 -4
- package/redis/bootstrap-acl.sh +130 -0
- package/sql/bootstrap.sql +218 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
What "notable" means for a published package: an entry earns a place here if it changes what an installed copy does or holds: the `bin`, a command and its arguments, the files in the tarball, a migration, `sql/bootstrap.sql`, `redis/bootstrap-acl.sh`. Repo plumbing that never reaches the tarball (`files` is `["dist", "sql", "redis", "CHANGELOG.md"]`; npm adds `package.json`, `README.md` and `LICENSE` on its own) is recorded under the release it landed in, marked as shipping no change to the package.
|
|
8
|
+
|
|
9
|
+
A new migration is a change to every service that installs the package: it reaches a service's CI only after a release and a range bump, like `@axiumine/qpanel-common`.
|
|
10
|
+
|
|
11
|
+
## [Unreleased]
|
|
12
|
+
|
|
13
|
+
## [0.9.0] - 2026-12-06
|
|
14
|
+
|
|
15
|
+
First release as the **public** package `@axiumine/qpanel-db-setup` (parent ADR-048). Up to 0.8.0 it was the private
|
|
16
|
+
`@thedoctorweb_agency/qpanel-db-setup`; the entries below name it as it was then.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- ⚠️ **The package is renamed and public.** A service replaces `@thedoctorweb_agency/qpanel-db-setup` with
|
|
21
|
+
`@axiumine/qpanel-db-setup` in its `package.json` dev dependency and in every path under `node_modules`; it needs no npm token
|
|
22
|
+
for it any more. `publishConfig.access` is `public`.
|
|
23
|
+
- The `bin`, the commands, the migrations, `sql/bootstrap.sql` and the files in the tarball are those of 0.8.0.
|
|
24
|
+
|
|
25
|
+
## [0.8.0] - 2026-12-04
|
|
26
|
+
|
|
27
|
+
Released as the tag `v0.8.0`.
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- The shared library is the public `@axiumine/qpanel-common` `^0.11.0`, no longer the private
|
|
32
|
+
`@thedoctorweb_agency/qpanel-common` (parent ADR-045). Same code; no migration.
|
|
33
|
+
- `sql/bootstrap.sql` names no host, subnet or machine any more: its closing hint shows `<postgres-host>`, and its `pg_hba` step
|
|
34
|
+
covers a Patroni cluster and a plain server alike. `redis/bootstrap-acl.sh` and `env.example` lose their machine-specific
|
|
35
|
+
wording the same way. Nothing the script creates changes.
|
|
36
|
+
|
|
37
|
+
## [0.7.0] - 2026-12-01
|
|
38
|
+
|
|
39
|
+
Released as the tag `v0.7.0`.
|
|
40
|
+
|
|
41
|
+
### Added
|
|
42
|
+
|
|
43
|
+
- Migration `20261201000000-ssh-login-per-way` (parent ADR-043): table `ssh_login`, a way to log in of an SSH user with its own
|
|
44
|
+
password, one-time code secret and notes. It is filled from `ssh_user`, which loses `logins`, `id_password_secret`,
|
|
45
|
+
`id_otp_secret` and `notes`. The password goes to the first way that asks a password, the one-time code secret to the first with
|
|
46
|
+
`keyboard-interactive` (each to the first way when none does), the notes to the first way; no `secret` row is touched. Reverting
|
|
47
|
+
it refuses while a user keeps two passwords or two one-time code secrets.
|
|
48
|
+
|
|
49
|
+
### Changed
|
|
50
|
+
|
|
51
|
+
- Takes `qpanel-common` 0.10.0, whose `Database` type has the new table.
|
|
52
|
+
- A run with `--test` asks Infisical for the one `*_TEST` URL it reads when that has no value (README, "Infisical"; ADR-041).
|
|
53
|
+
- The gates take a test setting or `QODANA_TOKEN` that no env file holds from Infisical. No change to the package.
|
|
54
|
+
|
|
55
|
+
## [0.6.0] - 2026-12-01
|
|
56
|
+
|
|
57
|
+
Released as the tag `v0.6.0`. It carries the same migrations as 0.5.0.
|
|
58
|
+
|
|
59
|
+
### Added
|
|
60
|
+
|
|
61
|
+
- With the `INFISICAL_*` settings, `migrate`, `keygrip` and `master-key rewrap` / `retire` fill the variables they read and
|
|
62
|
+
that are unset from a self-hosted Infisical (README, "Infisical"; ADR-040). Never for a run with `--test`.
|
|
63
|
+
|
|
64
|
+
### Changed
|
|
65
|
+
|
|
66
|
+
- Takes `qpanel-common` 0.9.0, which carries the Infisical client.
|
|
67
|
+
|
|
68
|
+
## [0.5.0] - 2026-11-30
|
|
69
|
+
|
|
70
|
+
Released as the tag `v0.5.0`. It carries every migration up to `20261130200000-create-server-ssh-access`.
|
|
71
|
+
|
|
72
|
+
### Added
|
|
73
|
+
|
|
74
|
+
- **The migration `20261130200000-create-server-ssh-access`** (parent ADR-039). `qpanel.ssh_access`: the address of a
|
|
75
|
+
server's SSH daemon, one row per server at most (`host`, `port` 22 by default, `knock_sequence` and
|
|
76
|
+
`knock_close_sequence` as `<port>/<tcp|udp>` lists of at most 16, `knock_delay_ms`, `knock_open_seconds`, `id_jump_user`:
|
|
77
|
+
the SSH user of another server it is reached through, which then cannot be deleted, nor can their server).
|
|
78
|
+
`qpanel.ssh_user`: accounts of a server, the name unique there, with `logins` (1 to 8 ways to log in, each a chain of at
|
|
79
|
+
most 4 of `publickey`, `password`, `keyboard-interactive`) and optional password and one-time secrets.
|
|
80
|
+
`qpanel.ssh_key`: keys of a user (`qpanel.ssh_key_kind`: `key`, `security_key`, `certificate`) with optional private key,
|
|
81
|
+
passphrase and PIN secrets. Deleting a server deletes all three and their secrets. Existing data is untouched; `down`
|
|
82
|
+
drops the tables, their functions and the enum. A database with this migration is one `qpanel-common` 0.8.0's `Database`
|
|
83
|
+
type describes.
|
|
84
|
+
|
|
85
|
+
### Changed
|
|
86
|
+
|
|
87
|
+
- Takes `qpanel-common` 0.8.0, so `master-key rewrap` re-wraps the SSH secrets: an older release refuses their purposes.
|
|
88
|
+
|
|
89
|
+
## [0.4.0] - 2026-11-30
|
|
90
|
+
|
|
91
|
+
Released as the tag `v0.4.0`. It carries every migration up to `20261130120000-create-server`.
|
|
92
|
+
|
|
93
|
+
### Added
|
|
94
|
+
|
|
95
|
+
- **The migration `20261130120000-create-server`.** The table `qpanel.server`: a machine of a datacenter, with a `name`
|
|
96
|
+
(`qpanel.citext`, unique within its datacenter) and optional `notes`; a datacenter that has a server cannot be deleted.
|
|
97
|
+
- `qpanel.service` gains `id_server` (optional; a server a service runs on cannot be deleted) and `host` (optional:
|
|
98
|
+
`localhost`, an IPv4 or an IPv6 address without a netmask, and only with a server: the check constraints
|
|
99
|
+
`service_host_address` and `service_host_needs_server`). The unique index `service_id_server_host_port_unique` allows one
|
|
100
|
+
service per server, host and port when all three are set; it compares the host as `inet` and reads `localhost` as
|
|
101
|
+
`127.0.0.1`. Existing services get neither value. `down` drops the columns and the table. A database with this migration is
|
|
102
|
+
one `qpanel-common` 0.7.0's `Database` type describes (`ServerTable`, `ServiceTable.idServer`, `ServiceTable.host`); older
|
|
103
|
+
services never name them and are unaffected.
|
|
104
|
+
- A subdomain label may be `@` (the domain itself), one per domain: the schema already allowed it, and the tests now prove it.
|
|
105
|
+
|
|
106
|
+
## [0.3.0] - 2026-11-30
|
|
107
|
+
|
|
108
|
+
Released as the tag `v0.3.0`. It carries every migration up to `20261130000000-db-instance-environments`.
|
|
109
|
+
|
|
110
|
+
### Added
|
|
111
|
+
|
|
112
|
+
- `sql/bootstrap.sql` creates a third role per environment, `qpanel_<env>_backup`, for dumps: `SELECT` on every table and sequence of
|
|
113
|
+
schema `qpanel`, existing ones and those later migrations create, and nothing else (no write, no DDL, no temporary table, at most 3
|
|
114
|
+
connections). Run the script again on an existing environment: it asks for the new role's password only.
|
|
115
|
+
- The variable `backup_password`, optional: a run that passes `migrator_password` or `app_password` is not asked for it and leaves the
|
|
116
|
+
new role without a password. A service's CI needs no change.
|
|
117
|
+
|
|
118
|
+
### Changed
|
|
119
|
+
|
|
120
|
+
- **Breaking for a service: the migration `20261130000000-db-instance-environments`** replaces `db_instance.environment`
|
|
121
|
+
(`qpanel.environment`, NULL for an instance shared by every environment) with `db_instance.environments text[] NOT NULL`, the
|
|
122
|
+
environments the instance serves (parent ADR-033). The table's check constraints require at least one value, only `development`,
|
|
123
|
+
`testing`, `staging` and `production`, no value twice, no NULL element and a list of one dimension. There is no default: whoever
|
|
124
|
+
inserts a row names its environments. An existing shared instance gets all four, any other the one it had, and no row's
|
|
125
|
+
`updated_at` moves. `down` goes back to one value: an instance with exactly one environment keeps it, one with several becomes
|
|
126
|
+
NULL (shared). A database with this migration is one `qpanel-common` 0.6.0's `Database` type describes
|
|
127
|
+
(`DbInstanceTable.environments`); a service that still names the old column fails against it. `subdomain.environment` is unchanged.
|
|
128
|
+
- `@thedoctorweb_agency/qpanel-common` stays `^0.2.0`: nothing here reads the table.
|
|
129
|
+
- Repo plumbing, **ships no change to the installed package's behaviour**: in a linked git worktree without its own env file, the hooks, `qodana.sh` and the tests read the main working tree's (ADR-029); the commit hook's secret guard also refuses a literal password or URL of the backup role (ADR-030).
|
|
130
|
+
- Repo plumbing, **ships no change to the installed package's behaviour**: a pushed tag `v<version>` publishes it (`.github/workflows/release.yml`: the gates, a self-hosted pack job, one GitHub-hosted publish job with npm trusted publishing) and `gates.yml` can be called as a workflow.
|
|
131
|
+
- Repo plumbing, **ships no change to the installed package's behaviour**: the commit hook's secret guard refuses a master key ring (by name and by content) and an age identity, and reads every staged file: a name git quotes, a link replaced by a file, a large file and a line with a NUL or a non-UTF-8 byte are scanned, and a `git diff` that fails refuses the commit.
|
|
132
|
+
|
|
133
|
+
### Fixed
|
|
134
|
+
|
|
135
|
+
- `redis/bootstrap-acl.sh`: a node that cannot be reached is reported and the nodes after it are still done. Before, the script ended at that node with no message, leaving the later nodes without the user or with its old password. A probe that never reaches its node no longer counts as a refusal.
|
|
136
|
+
|
|
137
|
+
## [0.2.0] - 2026-11-28
|
|
138
|
+
|
|
139
|
+
Released as the tag `v0.2.0`. It carries every migration up to `20261128000000-secret-value-changed-at`.
|
|
140
|
+
|
|
141
|
+
### Added
|
|
142
|
+
|
|
143
|
+
- **The migration `20261128000000-secret-value-changed-at`: `secret.value_changed_at timestamptz NOT NULL DEFAULT now()`**, when the **value** of a secret last changed. `updated_at` cannot answer "secrets older than 12 months": the trigger `secret_set_updated_at` bumps it on every update, and `master-key rewrap` updates every row, so a re-wrap would reset the age of every secret. A service writes the new column when it creates or replaces a password; **`master-key rewrap` never does** (it still writes only `wrapped_dek`, `key_version` and `rotated_at`, which `test/integration/masterKey.test.mts` now proves: after a run every secret keeps its `value_changed_at` while the re-wrapped ones get a later `updated_at`). Existing rows are backfilled with `updated_at`, the latest moment their value can have changed. The backfill is an `UPDATE`, so the migration switches `secret_set_updated_at` off for that one statement and on again right after, inside its transaction: left on, it would have turned `updated_at` into the migration's own time on every row, destroying the date it copies. `down` drops the column. The app role keeps its table-wide grants, which cover a column added later. A database that has this release applied is one `qpanel-common` 0.3.0's `Database` type describes (`SecretTable.valueChangedAt`); older services never name the column and are unaffected.
|
|
144
|
+
|
|
145
|
+
### Changed
|
|
146
|
+
|
|
147
|
+
- Repo plumbing, **ships nothing of its own**: the committed schema snapshot gains the column, `migrations.test.mts` proves the backfill (the dates survive, `updated_at` is untouched, the trigger is armed again and still moves only `updated_at`) and `down`, and `schema.test.mts` proves the column's rules (required, defaults to `now()`, untouched by any other update, readable and writable by the app role).
|
|
148
|
+
- `@thedoctorweb_agency/qpanel-common` stays `^0.2.0`: nothing here reads the new column, and `rewrapSecrets` selects its columns by name.
|
|
149
|
+
|
|
150
|
+
## [0.1.0] - 2026-11-28
|
|
151
|
+
|
|
152
|
+
The first release, tagged `v0.1.0`. It carries every migration up to `20261127001800-billing-fields`.
|
|
153
|
+
|
|
154
|
+
### Added
|
|
155
|
+
|
|
156
|
+
- **The package.** `@thedoctorweb_agency/qpanel-db-setup` is a private npm package (ADR-022; licence `AGPL-3.0-or-later`, as `qpanel-common`, ADR-018), so a service's CI can build the real `qpanel_test` schema in a throwaway PostgreSQL 18.7: `sql/bootstrap.sql` as the container's superuser, then every migration as the test migrator. It ships compiled JavaScript (`dist/src/*.mjs` and `dist/migrations/*.mjs`: Node does not strip types under `node_modules`), `sql/bootstrap.sql`, `redis/bootstrap-acl.sh` and this changelog. The migrations keep the names they have in the repo, so a database migrated from the package and one migrated from a checkout are the same database.
|
|
157
|
+
- **The `qpanel-db-setup` bin** (`dist/src/bin.mjs`): `migrate up|down|status [--test]`, reading `DATABASE_MIGRATOR_URL` (`DATABASE_MIGRATOR_URL_TEST` with `--test`) exactly as the repo's `yarn migrate:*` do, plus `master-key mint|add-version|rewrap|retire` and `keygrip seed|rotate|retire`. It finds the migrations inside the installed package, not under the caller's working directory. `migrate up` and `up` are the same command: the repo's scripts keep the short spelling.
|
|
158
|
+
|
|
159
|
+
### Changed
|
|
160
|
+
|
|
161
|
+
- `@thedoctorweb_agency/qpanel-common` `^0.2.0` (was `^0.1.0`). Nothing used here changed in it: the master key ring, the secret cipher, `createDatabase`, the `Database` type and the Keygrip stores are the same.
|
|
162
|
+
- `create <name>` refuses to run from an installed copy (a folder under `node_modules`): a new `.mts` file there would be neither compiled nor loadable. Run it in a checkout.
|
|
163
|
+
- The usage text names the bin (`qpanel-db-setup <command>`) and lists the migration commands as `migrate up|down|status`.
|
|
164
|
+
- Repo plumbing, **ships nothing of its own**: `yarn build` (`tsc -p tsconfig.build.json`, then `chmod +x` on the bin) and `prepack`; `test/integration/package.test.mts` packs the tarball with `npm pack`, extracts it under a `node_modules` folder and runs the installed bin against `qpanel_test` (the exact file list, the manifest, `migrate status|up|down`, the schema it leaves against the committed snapshot).
|