3 ms·
Are migrations still specified in json?
by colemannerd 2y ago
Are migrations still specified in json?
- tudorg 2y agoYes, but we're working on a converter from DDL sql to pgroll json. The reason for JSON is because the pgroll migrations are "higher level". For example, let's say that you are adding a new unique column that should infer its data from an existing column (e.g. split `name` into `first_name` and `last_name`). The pgroll migration contains not only the info that new columns are added, but also about how to backfill the data. The sql2pgroll converter is creating the higher level migration files, but leaves placeholder for the "up" / "down" data migrations. The issue where sql2pgroll is tracked is this one: https://github.com/xataio/pgroll/issues/504 https://github.com/xataio/pgroll/issues/504
- colemannerd 2y agoThank you so much! I’ll be watching
- solatic 2y agoI completely understand the need for a higher-level language above SQL, but straight JSON is a deal-breaker. It's not just comments, it's also that editors won't understand that JSON should have syntax-highlighting to help people catch trivial typos. A configuration language that allows for importing a file as a string would allow users to write the SQL in files with .sql extensions and get syntax-highlighting. pgroll is written in Go, so if you were to accept configuration written in CUE, you would get the best of all worlds: * Besides support for comments, there's first-class support in Go for writing configuration in CUE and then importing it: https://cuelang.org/docs/concept/how-cue-works-with-go/#loading-cue-data https://cuelang.org/docs/concept/how-cue-works-with-go/#load... * SQL can written in files with .sql extensions and embedded in CUE with @embed: https://cuelang.org/docs/howto/embed-files-in-cue-evaluation/ https://cuelang.org/docs/howto/embed-files-in-cue-evaluation...
- joelhaasnoot 2y agoLol, it's funny you need a higher level language and choose... JSON.
- mdaniel 2y agohttps://github.com/xataio/pgroll/issues/281 https://github.com/xataio/pgroll/issues/281 may be worth a :+1: even though it seems from tudorg's comment that they're really wedded to .json :-(
- tudorg 2y agoHa ha, we're not wedded, I was only explaining why a .sql file is not quite enough. Using some json equivalent should be fine, thanks for pointing to the issue.