[LRUG] Rails schema line order changing
Ed Jones
ed at error.agency
Mon Mar 1 11:44:09 PST 2021
Hi Stuart
While this doesn't necessarily sort the order of the columns in a table (isn't that set when you generate the migration?), we have had some success reworking the order of the schema dumper by prepending a module which defines dump() in the order we want. This is particularly useful if you have functions which are predicated on the existence of views, or whatever.
https://gist.github.com/edtjones/864ad38346cd91c9ec38157a6b8007e0 <https://gist.github.com/edtjones/864ad38346cd91c9ec38157a6b8007e0>
(We use FX and Scenic gems for functions, triggers and views in Postgres)
Ed
> On 1 Mar 2021, at 08:09, Stuart Harrison <pezholio at gmail.com> wrote:
>
> Morning LRUG
>
> I wanted to share an annoyance I've had on multiple projects, and wondered if anyone had any fixes for it?
>
> If there are multiple devs on a project committing a bunch of migrations and running `db:migrate`, it seems that, over time, the order of columns in the schema.rb file jumps around every time the command is run.
>
> I can get around this by only committing the relevant line(s) when I run a migration, but this does get annoying.
>
> I'm sure there is a solution, but it's disappeared out of my head, and seems to be an ungoogleable problem, so was wondering if anyone had come across a solution?
>
> Cheers
>
> Stu
> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org
> Archives: http://lists.lrug.org/pipermail/chat-lrug.org
> Manage your subscription: http://lists.lrug.org/options.cgi/chat-lrug.org
> List info: http://lists.lrug.org/listinfo.cgi/chat-lrug.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20210301/8c51926e/attachment.html>
More information about the Chat
mailing list