3 ms·
Yeah, I’m aware of that, thank you. I was wondering if there was a way with a faster feedback loop and allowed for bug fixes without creating a new migration.
by jwdunne 6y ago
Yeah, I’m aware of that, thank you. I was wondering if there was a way with a faster feedback loop and allowed for bug fixes without creating a new migration.
- skdv 6y agoYou don't need to write the migration until you're done. It's possible to have a very tight feedback loop in any case. I'm doing a lot of work in a Rails codebase where I edit views/functions/procedures all the time. My setup is quite usable. My current setup: I edit those .sql files and run them with psql in my local while developing (without writing any migration yet). I have some like this running on one screen to make sure the modified files are executed by psql immediately as I change them (you could use `guard` too): find ~/projectx/db/functions -type f -name "*.sql" | entr -d -p psql db_name -f /_ and I edit the db/functions/*.sql files freely, adding things, changing behaviour of functions and they are updated on the fly. (I can run tests -or try things in the browser- to verify my changes work as I expect). -- Once I finish and I know everything is great, I just add the migration. The migration is simply an indicator of which files I've modified and to specify the right order to run them (which is useful if they are dependencies), like: # migration def up execute File.read(function1_sql_file) execute File.read(function2_sql_file) end I could have an alias that automates generating that migration but it's just 4 lines... [ I'm also using pgTAP to write tests for functions, it's quite nice :) ]
- jwdunne 6y agoOh wow, now I see what you mean. Thank you! That’s work great. I wasn’t aware of ‘entr’ either, that’s exactly what I had in mind! I’ll have a look at pgTAP too. Naturally we want to test in CI, I can see this working really well. I did look at myTAP too, since we have a few MySQL instances.