Is there any trivial way to copy the data from developmenet database into the test one? I know theres a way to copy schema and recreate database, but is there any rake task to populate test database with development one?
相关问题
- Question marks after images and js/css files in ra
- Using :remote => true with hover event
- Dependencies while implementing Mocking in Junit4
- Eager-loading association count with Arel (Rails 3
- How to unit test a reactive component where ngCont
相关文章
- How to replace file-access references for a module
- How to mock methods return object with deleted cop
- Right way to deploy Rails + Puma + Postgres app to
- What is a good way of cleaning up after a unit tes
-
EF6 DbSet
returns null in Moq - AWS S3 in rails - how to set the s3_signature_vers
- how to call a active record named scope with a str
- How to add a JSON column in MySQL with Rails 5 Mig
An alternative method if you use seeds (db/seeds.rb)
First, add a rake task for example to lib/tasks/test_seed.rake with this code:
Then whenever you changed your database structure / content through migration and seeds, you can run
To copy the schema and seed data.
So the complete steps would be:
If you just want to clone the development DB in its entirety, what's wrong with just copying the development.sqlite3 and renaming it test.sqlite3? You can automate the process by setting up a batch file (or its equivalent on your OS) that you can run from the command line.
This will work locally, but I just realized you might be thinking a non-local environment, in which case it probably won't.
With Postgres, copy the database like so:
You can use mysql directly:
You can use:
To copy the development db into test.
For all databases: