As a developer, I find schema migrations a pain. I’m not using an ORM, so I write my SQL schemas by hand, including any subsequent
ALTER TABLE queries, and use https://github.com/golang-migrate/migrate to sync them.
However, it would be much nicer if I could just define my schema declaratively in SQL using
CREATE TABLE statements, and have cockroach deal with the changes to columns/indexes etc each time I pass up my schema.
There is some tooling in this space already. The closest thing I’ve found to this is https://www.skeema.io/ but this is MySQL only. It is also my opinion that this is best implemented in the database as it reduces the moving parts and things that can go wrong, especially for something that is so critical. I’m also aware that Prisma V2 will also solve this problem, but I’ve not seen much in the way of a CockroachDB integration.
Obviously there are some issues that would be ironed out, such as what should happen regarding a destructive change like dropping columns or indexes. Perhaps there would be scope for expanding the “jobs” section on the dashboard to resolve these types of issues.
I’m not exactly sure what the whole thing looks like, or the complexities involved, but I’m sure that many developers and teams would benefit from this.
Is there room for this feature to be implemented into CockroachDB?
I welcome any feedback and would love to hear how others are dealing with schema changes.