Search code examples
spring-bootcassandracockroachdbtimeuuid

How to generate a version1 uuid in Cockroachdb


Our current datastore is Cassandra. We're planning to move away from it towards Cockroachdb wherein we need to refactor our code(Spring boot). The current scripts use the datatype 'timeuuid' which gives a version1 uuid in Cassandra. Now, I need a similar datatype in CockroachDb which will be feasible to store the existing data (when we migrate in bulk) and also to create new data for that column ('created_at').

I found a builtin in CockroachDb docs which is related to ulid but ulid's format is different from a version1 uuid.

Any ideas what can I use instead?


Solution

  • CockroachDB is adding support for the uuid_generate_v1() builtin function in v22.2, which is coming out later in 2022. Until then, you'd need to generate the UUID within your application.