How to recreate test instruments based on a development database schema

Situation: I used to generate a scaffold to set up my objects in a new Rails project. Besides doing some migrations, I also directly edited MySQL tables, adding and renaming columns, etc. Now I can not run the tests because the automatically generated devices do not match the database schema. Perhaps they are based on the original definitions plus migrations, and my migrations do not fully describe the new structure.

I found that I could use "rake db: test: clone_structure" to duplicate tables in a test database (db: test: prepare, obviously creates them from migrations?), But I cannot figure out how to get which are created from development schemes, not from migrations (or something else).

I realized that there is a Fixtures.create_fixtures method, but where would I put it and how would I use it to restore all my devices?

+4
source share
2 answers

When working with rails, you never do this - "directly edit MySQL tables, adding and renaming columns" you create migrations

http://guides.rubyonrails.org/migrations.html

+3
source

I completely agree that you should not change the database without using migrations, but reconstructing fixtures is still a problem that people occasionally encounter. The best solution I found here:

http://snippets.dzone.com/posts/show/2525

+1
source

All Articles