Manipulating the database schema on app start-up

Hi roachers,

I’ve found myself in a tricky situation. I want the apps connecting to Cockroach databases to update the schemas by adding new columns and constraints on Startup. For Postgres that works fine when using Spring Boot and Hibernate with the command spring.jpa.hibernate.ddl-auto = update

The above command does not work with Cockroach. I am forced to advise my team to use spring.jpa.hibernate.ddl-auto = create.

How do i achieve the same with Cockroach?

Moses King’ori

Your description isn’t really helpful. Which errors do you get?

It’s not an answer to you question, but may be it can help you. From my perspective ddl-auto should be used only for prototyping, but not for development. And should be forbidden for production. It can mess things and can’t migrate your data. Therefore, think about to use a database migration tooling. Most of people use flyway or liquibase. Personally, I like to work with mybatis migrations (can be used without mybatis). Look at mybatis-migrations-spring-boot-autoconfigure for spring integration I’ve created and used in the past. Now I’m switching to knex migrations (Node.js).