<div dir="ltr">Not sure if this is what you're asking, but I wrote a blog post about using migrations to move a legacy database into a state where a new project with a *different schema* can use it: <a href="https://dgmstuart.github.io/blog/2014/08/20/migrating-postgres-data-from-an-old-rails-project-to-a-new-one/">https://dgmstuart.github.io/blog/2014/08/20/migrating-postgres-data-from-an-old-rails-project-to-a-new-one/</a><br></div><div class="gmail_extra"><br><div class="gmail_quote">On 16 March 2016 at 22:10, Graham Ashton <span dir="ltr"><<a href="mailto:graham@effectif.com" target="_blank">graham@effectif.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Wed, 16 Mar 2016, at 18:59, gvim wrote:<br>
><br>
> My tentative approach is to do away with an initial "create" migration<br>
> and substitute it with the output an initial pg_dump. Will subsequent<br>
> migrations work, assuming there will never be a need to recreate the db<br>
> solely from Rails migrations?<br>
<br>
As I was reading your post and saw how you'd made an initial migration using the output of a dump, it struck me as odd. Did you find that approach documented somewhere?<br>
<br>
It seems a little too likely to fiddle (needlessly) with your data to me.<br>
<br>
Did you try just starting with your legacy database, and using migrations to manage schema changes moving forward? I'd be surprised if it didn't just work (though I've never tried it, so I could be talking rubbish).<br>
<br>
Rails keeps track of the migrations that have been run in a schema_versions table. I don't know when that gets created – it could be made automatically when you run your first migration, in which case you're good to go.<br>
<br>
If not, it's very simple, and only has one column, so you could make it yourself.<br>
<br>
As for recreating the db solely from migrations, don't worry about needing to do it. The schema:load rake task the recommended way to create a new empty database.<br>
<br>
It's actually a good idea to remove old migrations from the db/migrate folder once you've no further use for them (i.e. they've been run on all instances of your database).<br>
<br>
Hope that makes some sense...<br>
_______________________________________________<br>
Chat mailing list<br>
<a href="mailto:Chat@lists.lrug.org">Chat@lists.lrug.org</a><br>
Archives: <a href="http://lists.lrug.org/pipermail/chat-lrug.org" rel="noreferrer" target="_blank">http://lists.lrug.org/pipermail/chat-lrug.org</a><br>
Manage your subscription: <a href="http://lists.lrug.org/options.cgi/chat-lrug.org" rel="noreferrer" target="_blank">http://lists.lrug.org/options.cgi/chat-lrug.org</a><br>
List info: <a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" rel="noreferrer" target="_blank">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a><br>
</blockquote></div><br></div>