[LRUG] Initial migration for new Rails 4 project using existing postgres db

Jon Wood jon at ninjagiraffes.co.uk
Thu Mar 17 03:06:48 PDT 2016


If you've got things like views that need handling as well your best bet is
probably Andrew's recommendation of setting the schema format to SQL - once
you're building views you've lost the benefit of being able to migrate
database engines anyway so there's no real benefit to translating all the
SQL into Ruby.

Once you've done that it should just be a case of creating the
schema_migrations table, and then writing migrations for any future changes
you want to make.

On Thu, 17 Mar 2016 at 09:58 Andrew Premdas <apremdas at gmail.com> wrote:

> Bit of googling found https://gist.github.com/vjt/4548844 - hopefully its
> useful. You'll probably have to create the database first, either using
> pg_create or the rails rake task. Also I'd recommend setting
>
> `Rails.application.config.active_record.schema_format` to  :sql in
> application.rb
>
> Hope that helps
>
> On 17 March 2016 at 04:14, gvim <gvimrc at gmail.com> wrote:
>
>> A while back I discovered a gem which generates Rails models from an
>> existing database. Can you think of any?
>>
>> gvim
>>
>> _______________________________________________
>> 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
>>
>
>
>
> --
> ------------------------
> Andrew Premdas
> blog.andrew.premdas.org
> _______________________________________________
> 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/20160317/dbd43d7f/attachment-0002.html>


More information about the Chat mailing list