Created
May 11, 2011 14:59
-
-
Save dhh/966615 to your computer and use it in GitHub Desktop.
Database design snapshots
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Designers need fleshed out pages to do properly design a screen. | |
In the past, we've loaded test fixtures in development to give them that. | |
But test fixtures are not a good fit for this. | |
They're designed to make testing easy, not designing. | |
What we need instead is a way for a designer to create a dataset | |
that'll work great for design and then save that as a snapshot. | |
This snapshot can be named and reloaded as often as desired. | |
I envision it'll work like this: | |
1) Designer starts with a clean database (although possibly preloaded with db/seeds.rb) | |
2) He creates all the data using the app itself. | |
3) He runs rake db:snapshots:capture NAME=jfbase that'll create db/snapshots/201105110953-jfbase.(rb/yml/sql/whatever) | |
3a) If no name is given, it'll create db/snapshots/201105110953.(rb/yml/sql/whatever) [timestamp] | |
This snapshot will record all the data in the tables at the time. | |
It'll also record the schema version of the database of the time of the dump. | |
When he wants to load the snapshot, he'll do | |
1) db:snapshots:load NAME=jfbase | |
1a) If no name is given, it'll load the latest snapshot | |
2) If the database is not empty, it'll ask for confirmation before overwriting everything: | |
"This database is not empty. Are you sure you want to erase it to load the snapshot? [y/n]" | |
You should be able to sidestep this using "--force-load". | |
If the schema version doesn't match the current database, it'll load the old schema, | |
then run the migrations needed to bring it up to date, | |
then save it again (so this dance isn't needed next time). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment