简体   繁体   中英

How do I import a development_structure.sql file into my test database in a rails rake task?

I'm using rails 2.3, and I've generated a development_structure.sql using

rake db:test:clone_structure

How do I import this into my test database? Is there a rails 2.3 compatible rake task for it?

I'm using development_structure.sql as a reference for the structure of my database (and not migrations) that I add to my repo, so I want an easy way to test different database structures as the database changes.

I think you can use

rake db:structure:dump RAILS_ENV=test

UPDATE: I don't know what's wrong with me today. You should use

rake db:setup RAILS_ENV=test

If I remember correctly, that will use structure.sql if you have the schema_format set to sql

Try this:

> rake db:test:prepare
Database mydb_test loaded from db/development_structure.sql.

Maybe you want to transform this .sql into fixtures? The database is recreated every time you do a rake test

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM