forked from adamwiggins/yaml_db
-
Notifications
You must be signed in to change notification settings - Fork 1
/
README
45 lines (23 loc) · 1.81 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
= YamlDb
YamlDb is a database-independent format for dumping and restoring data. It complements the the database-independent schema format found in db/schema.rb. The data is saved into db/data.yml.
This can be used as a replacement for mysqldump or pg_dump, but only for the databases typically used by Rails apps. Users, permissions, schemas, triggers, and other advanced database features are not supported - by design.
Any database that has an ActiveRecord adapter should work.
== Usage
rake db:data:dump [TABLE=xxx] -> Dump contents of Rails database to db/data.yml, you can specify the table you want to dump by providing the TABLE option, if it's a bunch of tables you want to dump, specify the table names separated by comma.
rake db:data:load -> Load contents of db/data.yml into the database
Further, there are tasks db:dump and db:load which do the entire database (the equivalent of running db:schema:dump followed by db:data:load).
== Examples
=== Dump all the tables in MySQL, and load the data to another database backend.
One common use would be to switch your data from one database backend to another. For example, let's say you wanted to switch from SQLite to MySQL. You might execute the following steps:
1. rake db:dump
2. Edit config/database.yml and change your adapter to mysql, set up database params
3. rake db:drop; rake db:create; rake db:migrate
4. rake db:load
=== Dump the specified table but all tables in the database.
1. rake db:dump TABLE=users
=== Dump several tables at one time
1. rake db:dump TABLE=users,profiles
== Credits
Created by Orion Henry and Adam Wiggins. Major updates by Ricardo Chimal, Jr.
Patches contributed by Michael Irwin, Tom Locke, and Tim Galeckas.
Send questions, feedback, or patches to the Heroku mailing list: http://groups.google.com/group/heroku