best-plumber-65600
05/26/2025, 3:51 AMpeople.schema.json
. I then renamed the file to user.schema.json
with the same values. What happens in this case? Will it remove the previous data?brief-egg-61061
05/26/2025, 3:51 AMbrief-egg-61061
05/26/2025, 3:51 AMpeople.schema.json
to user.schema.json
and updating the Kratos configuration to reference the new filename does not remove or alter any existing identity data. The schema file itself is only used for validating identity traits during creation or update operations. However, here’s what happens in detail: - Existing Identities: Identities that were created using the old schema (people.schema.json
) will continue to reference that schema by its configured ID or URL. Changing the filename and updating the configuration to point to user.schema.json
only affects new identities or updates that use the new schema reference. - Data Retention: No identity data is deleted or removed automatically by renaming the schema file or changing the configuration. Existing identities remain valid and continue to use the schema they were created with, unless you explicitly migrate them to the new schema. - Schema Versioning: The recommended approach is to version your schemas. If you want to migrate all identities to the new schema, you need to list all identities using the old schema and update them via the API, performing any necessary data transformations. This process is manual and not automatic upon renaming or reconfiguring the schema file [Identity schema best practices](https://www.ory.sh/docs/kratos/manage-identities/best-practices). In summary, simply renaming the schema file and updating the configuration will not remove previous data or affect existing identities. You must handle migrations explicitly if you want all identities to use the new schema.best-plumber-65600
05/26/2025, 4:14 AMbrief-egg-61061
05/26/2025, 4:14 AMbrief-egg-61061
05/26/2025, 4:14 AMtraits
object and set its type to "object"
. You can also use "additionalProperties": true
if you want the object to be schema-less and flexible. Here’s an example from the knowledge sources: json { "$id": "<https://example.com/person.schema.json>", "$schema": "<http://json-schema.org/draft-07/schema#>", "title": "Person", "type": "object", "properties": { "traits": { "type": "object", "properties": { "username": { "type": "string", "<http://ory.sh/kratos|ory.sh/kratos>": { "credentials": { "password": { "identifier": true } } } }, "custom_data": { "type": "object", "additionalProperties": true } }, "required": ["username"] } }, "additionalProperties": false }
In this example, the custom_data
attribute is a JSON object and can hold arbitrary key-value pairs. This approach is schema-less and very flexible, allowing you to store custom structured data as needed [Possibility to define complex data types in the metadata of identity](https://github.com/ory/network/issues/187).best-plumber-65600
05/26/2025, 4:21 AMbrief-egg-61061
05/26/2025, 4:22 AMbrief-egg-61061
05/26/2025, 4:22 AM"array"
and specifying "items"
as an object schema. Here is an example based on the knowledge sources: json { "$id": "<https://example.com/person.schema.json>", "$schema": "<http://json-schema.org/draft-07/schema#>", "title": "Person", "type": "object", "properties": { "traits": { "type": "object", "properties": { "custom_objects": { "type": "array", "items": { "type": "object", "properties": { "key": { "type": "string" }, "value": { "type": "string" } }, "required": ["key", "value"] } } } } } }
This schema allows the custom_objects
trait to be an array of objects, each with a key
and value
property. While the knowledge sources provide examples of arrays of strings and objects as traits, they do not explicitly show an array of objects. However, since Ory Kratos identity schemas are based on standard JSON Schema, this approach is supported and aligns with the documented usage of JSON Schema types in identity schemas [Customize identity schemas](https://www.ory.sh/docs/kratos/manage-identities/customize-identity-schema). If you need a schema-less array of objects, you can use "additionalProperties": true
inside the object definition. If you want to restrict the structure, define the properties as shown above. If you need further confirmation or advanced use cases, please consult the [official JSON Schema documentation](https://json-schema.org/understanding-json-schema/reference/array.html) as referenced in the Ory documentation.