Commit Graph

11 Commits

Author SHA1 Message Date
Arne Luenser 38efece55b
fix: migrations on CockroachDB v25+ (#3994)
I've added some output to the generated migrations files to make them
easier to recreate, hence the big diff.

These are important:

```
persistence/sql/migrations/20211004110001000000_change_client_primary_key.cockroach.down.sql
persistence/sql/migrations/20211004110001000000_change_client_primary_key.cockroach.up.sql
persistence/sql/migrations/20211004110003000000_change_client_primary_key.cockroach.down.sql
persistence/sql/migrations/20211004110003000000_change_client_primary_key.cockroach.up.sql

persistence/sql/migrations/20211011000001000000_change_jwk_primary_key.cockroach.down.sql
persistence/sql/migrations/20211011000001000000_change_jwk_primary_key.cockroach.up.sql
persistence/sql/migrations/20211011000003000000_change_jwk_primary_key.cockroach.down.sql
persistence/sql/migrations/20211011000003000000_change_jwk_primary_key.cockroach.up.sql

persistence/sql/src/20220210000001_nid/20220210000001000000_nid.cockroach.up.sql
```

Closes #3964 
Supersedes #3993 (thanks @hperl)
2025-05-20 08:56:06 +02:00
hackerman d27882faf1
feat: add migrate sql up|down|status (#3894)
This patch adds the ability to execute down migrations using:

```
hydra migrate sql down -e --steps {num_of_steps}
```

Please read `hydra migrate sql down --help` carefully.

Going forward, please use the following commands

```
hydra migrate sql up ...
hydra migrate sql status ...
```

instead of the previous, now deprecated

```
hydra migrate sql ...
hydra migrate status ...
```

commands.

See https://github.com/ory-corp/cloud/issues/7350
2024-11-27 14:14:13 +01:00
Arne Luenser 93edc9ad89 chore: remove json1 build tag everywhere
This is no longer necessary since SQLite 3.38, and was in fact removed completely in go-sqlite v1.14.13
2024-08-30 12:29:35 +02:00
Arne Luenser d686795eed chore: compile a static binary in Docker to move from distroless/static-debian12 to distroless/base-nossl-debian12 to get fewer CVE alerts
Uses the technique described in https://www.arp242.net/static-go.html
2024-08-30 12:29:35 +02:00
Arne Luenser cd7e7eff91
feat: upgrade to jackc/pgx/v5 (#3798) 2024-08-29 13:53:03 +00:00
aeneasr 36ddb61557 fix: use --yes flag in db-diff 2022-09-07 08:10:31 +02:00
aeneasr c38e700f7b chore: add json1 tag to db-diff 2022-09-07 08:10:31 +02:00
aeneasr a006b04882 fix: conditionals in db-diff 2022-09-07 08:10:31 +02:00
Grant Zvolsky 00490cbbc5 code review: generate first NID randomly; add/update tests; fix db-diff 2022-09-07 08:10:31 +02:00
Grant Zvolsky a2c5e14204 feature: create networks table 2022-09-07 08:10:31 +02:00
Grant Zvolsky 53862f290c refactor: improve performance and reduce data use of consent persistence layer (#2836)
This patch changes the internal data structure and reduces four (sort of redundant) tables into one. As part of this change, a few new tools have been added:

* Introduce the `hydra sql gen` command and a convenience Make target with autocompletion. The command reads migration templates from a source directory and produces migration files in a target directory. Its main function is to split a single source file into multiple files using split marks.

* Introduce the `hack/db-diff.sh` command to generate database schema diffs at different commits. This script is used to view and review the impact of migrations on the database schema.

BREAKING CHANGES: This patch merges four SQL Tables into a new table, deleting the old tables in the process. The migrations in this patch are expected to be applied offline. Please be aware that *there are no down migrations*, and if something goes wrong, data loss is possible. Always back up your database before applying migrations. For more information, see [Hydra 2.x Migration Guide](https://www.ory.sh/hydra/docs/guides/migrate-v2).

Rows with NULL login_challenge in `hydra_oauth2_consent_request` and corresponding `hydra_oauth2_consent_request_handled` are deleted as a side effect of the merge migration. This is done with the assumption that only a very small number of sessions, issued by pre-1.0 Hydra, will be affected. Please contact us if this assumption doesn't apply or if the deletion adversely affects your deployment.

Signed-off-by: Grant Zvolsky <grant@zvolsky.org>
2022-09-07 08:10:31 +02:00