Open nikolay opened 2 years ago
Indeed we have to parse out the statements, but this was an explicit decision made a long long time ago.
This hasn't really been an issue so far (at least based on all the teams I've worked on that used goose).
Maybe subjective, but I prefer a single migration file that captures both up and down. It looks cleaner when you have a lot of migrations.
What if I want to automatically extract the migration? Then I need to parse the file myself. In general, when the files are sorted, they will one after another, so, it's no less clean looking into the directory. Other frameworks do use separate files and the ones that use a single file are influenced by Ruby, but in Ruby language constructs are used, no comments, which are not even standard across migration frameworks that use comments! I am only saying allow both so different people will use different approaches.
For what it's worth, one of the reasons we choose Goose was because it halved the number of files we have to deal with.
@JasonPMC Absolutely all recent database migration frameworks use a single file per step! A great differentiator would be giving users an option to pick though!
I agree, it will be more convenient than single file.
@nightlord189 Convenient in what sense? What if you mess up the markup and migration goes wrong executing both directions?!
Another consideration is upstream tools that rely on goose migrations having a known file structure. One popular tool that comes to mind is https://github.com/sqlc-dev/sqlc, they expect this file format:
Relying on comments and mixing code that both creates and destroys in one file is not ideal. Many frameworks support filename schemes such as
<MIGRATION_ID>.up.sql
and<MIGRATION_ID>.down.sql
, so, ideally, Goose should support it, too.