kratos/persistence/sql
Patrik f7b5a646cb chore: remove internal address types
GitOrigin-RevId: 0747fafb24ad69bdee50488fdd1baa64a2988954
2025-12-08 15:16:09 +00:00
..
batch chore: fix kratos linting issues 2025-09-29 16:21:02 +00:00
devices chore: format 2025-07-01 17:10:26 +00:00
identity chore: remove internal address types 2025-12-08 15:16:09 +00:00
migratest test: fix data races 2025-12-04 16:12:25 +00:00
migrations fix: add missing indices on identity_id 2025-11-24 12:59:14 +00:00
stub feat: remove duplicate queries from whoami calls (#2995) 2023-01-10 14:35:08 +01:00
testhelpers fix: update year 2023-01-03 08:22:16 +01:00
update feat: faster UpdateIdentity 2025-11-03 12:51:53 +00:00
.soda.yml Clean up cmd and resolve packr2 issues (#211) 2020-01-31 15:06:08 +01:00
README.md feat: replace message_ttl with static max retry count (#2638) 2022-08-04 16:18:22 +02:00
persister.go feat: make new identity_id column on identifiers and session_devices NOT NULL and establish foreign key 2025-11-21 17:01:54 +00:00
persister_cleanup_test.go chore: fix kratos linting issues 2025-09-29 16:21:02 +00:00
persister_code.go chore(kratos): simplify internal APIs 2025-08-19 08:23:18 +00:00
persister_continuity.go chore(kratos): simplify internal APIs 2025-08-19 08:23:18 +00:00
persister_courier.go chore: remove counting courier messages 2025-09-25 08:48:12 +00:00
persister_errorx.go chore: format 2025-07-01 17:10:26 +00:00
persister_hmac.go feat: improved tracing 2025-12-03 14:44:34 +00:00
persister_hmac_test.go chore(kratos): simplify internal APIs 2025-08-19 08:23:18 +00:00
persister_login.go chore(kratos): simplify internal APIs 2025-08-19 08:23:18 +00:00
persister_login_code.go chore(kratos): simplify internal APIs 2025-08-19 08:23:18 +00:00
persister_recovery.go chore(kratos): simplify internal APIs 2025-08-19 08:23:18 +00:00
persister_recovery_code.go chore(kratos): simplify internal APIs 2025-08-19 08:23:18 +00:00
persister_registration.go chore(kratos): simplify internal APIs 2025-08-19 08:23:18 +00:00
persister_registration_code.go chore(kratos): simplify internal APIs 2025-08-19 08:23:18 +00:00
persister_session.go feat: add column identity_id to identity_credential_identifiers and session_devices 2025-11-11 11:57:23 +00:00
persister_sessiontokenexchanger.go chore(kratos): simplify internal APIs 2025-08-19 08:23:18 +00:00
persister_settings.go chore: fix kratos linting issues 2025-09-29 16:21:02 +00:00
persister_test.go test: fix data races 2025-12-03 14:17:52 +00:00
persister_transaction_helpers.go chore(kratos): simplify internal APIs 2025-08-19 08:23:18 +00:00
persister_verification.go chore(kratos): simplify internal APIs 2025-08-19 08:23:18 +00:00
persister_verification_code.go chore(kratos): simplify internal APIs 2025-08-19 08:23:18 +00:00

README.md

SQL Migrations

Migrations consist of one up and one down file. To create these SQL migrations, copy the last migration in ./persistence/sql/migrations/sql and change the timestamp to the current timestamp and the name to the desired name.

If some logic is different for one of the database systems, add the id after the name to the file name. The content of that file will override the content of the "general" file for that particular DB system.

Example:

20220802103909000000_courier_send_count.up.sql and 20220802103909000000_courier_send_count.down.sql

With for example cockroach specific behavior:

20220802103909000000_courier_send_count.cockroach.up.sql and 20220802103909000000_courier_send_count.cockroach.down.sql

Replace cockroach with mysql, postgres or sqlite if applicable.

Old Way

To create SQL migrations, target each database individually and run

$ dialect=mysql  # or postgres|cockroach|sqlite
$ name=
$ ory dev pop migration create -d=$dialect ./persistence/sql/migrations/templates $name
$ soda generate sql -e mysql -c ./persistence/sql/.soda.yml -p ./persistence/sql/migrations/templates [name]
$ soda generate sql -e sqlite -c ./persistence/sql/.soda.yml -p ./persistence/sql/migrations/templates [name]
$ soda generate sql -e postgres -c ./persistence/sql/.soda.yml -p ./persistence/sql/migrations/templates [name]
$ soda generate sql -e cockroach -c ./persistence/sql/.soda.yml -p ./persistence/sql/migrations/templates [name]

and remove the sqlite part from the newly generated file to create a SQL migrations that works with all aforementioned databases.

Rendering Migrations

Because migrations needs to be backwards compatible, and because fizz migrations might change, we render fizz migrations to raw SQL statements using make migrations-render.

The concrete migrations being applied can be found in ./migrations/sql.