0

Is there any way to take a running database and generate a migration file from it? If not does anyone have any advice on how to approach that?

Background: Have a new project where a PHP developer jumped into a rails project and starting adding tables and columns though PostGres admin tool.

6
  • you mean you want to reverse the added columns from the table. essentially remove the added migrations? Commented May 16, 2014 at 0:28
  • 1
    Generate a schema of the running database. I think i may have found rake -T db:schema:dump Commented May 16, 2014 at 0:29
  • You could just manually add the tables and columns to your schema.rb file. Commented May 16, 2014 at 0:30
  • yeah, try that rake command. usually, you shouldn't touch the schema file. the fields should populate once you run the migration Commented May 16, 2014 at 0:31
  • True, stackoverflow.com/questions/11301009/… That answer also suggests db:schema:dump task, which will update your db/schema.rb file to match the structure of your database. Commented May 16, 2014 at 0:36

1 Answer 1

2

Created a directory called "log" then ran this command

RAILS_ENV=production rake db:schema:dump
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.