3 ms·
My favorite copilot moment recently is rails migrations. I write the up migrating n, copilot gets the down migration right 90% of the time. It's wild. And thes
by phamilton 5y ago
My favorite copilot moment recently is rails migrations. I write the up migrating n, copilot gets the down migration right 90% of the time. It's wild.
And these aren't vanilla "change" commands. It's triggers and check constraints and changing column types and stuff.
- pqdbr 5y agoNot using Copilot yet, would appreciate if you could provide some real examples on what you typed and what copilot suggested.
- phamilton 5y agoWhen I type: def up execute <<-SQL alter table users add constraint active_users_must_have_email check active = false OR email is not null NOT VALID SQL i.e. I am adding a check constraint but making it NOT VALID so it won't lock the table while scanning If I continue and write execute <<-SQL a then it completes it with alter table users And then the next line I type v and it completes it with validate constraint active_users_must_have_email SQL I then type end and it suggests: def down execute <<-SQL ALTER TABLE users DROP CONSTRAINT IF EXISTS constraint active_users_must_have_email; SQL end Which is exactly what I needed. What impresses me is that a) it recognized that a NOT VALID index needs to be VALIDATEd and b) it figured out what the down migration was.