git_friendly_dumper 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +10 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +48 -0
- data/Rakefile +43 -0
- data/features/dump/change_dump_path.feature +26 -0
- data/features/dump/data_dump.feature +27 -0
- data/features/dump/default_dump.feature +39 -0
- data/features/dump/dump_and_raise_error.feature +58 -0
- data/features/dump/dump_deleted_records_and_clobber.feature +98 -0
- data/features/dump/dump_specific_tables.feature +39 -0
- data/features/load/clobber_load.feature +49 -0
- data/features/load/db_dump_path_load.feature +63 -0
- data/features/load/default_load.feature +103 -0
- data/features/load/load_and_raise_error.feature +97 -0
- data/features/load/load_fixtures.feature +159 -0
- data/features/load/load_git_changes.feature +17 -0
- data/features/load/load_specific_tables.feature +119 -0
- data/features/step_definitions/app_steps.rb +25 -0
- data/features/step_definitions/database_steps.rb +172 -0
- data/features/support/announce.rb +3 -0
- data/features/support/env.rb +2 -0
- data/features/support/logger.rb +7 -0
- data/lib/git_friendly_dumper.rb +279 -0
- data/lib/git_friendly_dumper/version.rb +3 -0
- data/lib/tasks/git_friendly_dumper_tasks.rake +51 -0
- data/spec/git_friendly_dumper_spec.rb +319 -0
- data/spec/resources/migrate/20070101000000_create_firsts.rb +11 -0
- data/spec/resources/migrate/20070101010000_create_seconds.rb +11 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/support/connect.rb +6 -0
- data/spec/support/logger.rb +7 -0
- metadata +196 -0
@@ -0,0 +1,63 @@
|
|
1
|
+
Feature: populate database with data and stucture in a custom directory
|
2
|
+
In order to load data found elsewhere than db/dump
|
3
|
+
I want the rake task to use the DUMP_PATH env variable to override the data path used
|
4
|
+
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given I am in an empty app
|
8
|
+
Given a Rakefile exists which has an environment task and loads git_friendly_dumper tasks
|
9
|
+
And an empty database
|
10
|
+
And a file named "db/dump/users/schema.rb" with:
|
11
|
+
"""
|
12
|
+
create_table "users", :force => true do |t|
|
13
|
+
t.string "wont_use"
|
14
|
+
t.string "this_schema"
|
15
|
+
end
|
16
|
+
|
17
|
+
"""
|
18
|
+
And a file named "db/dump/users/0000/0001.yml" with:
|
19
|
+
"""
|
20
|
+
---
|
21
|
+
name: shouldnt
|
22
|
+
surname: be_loaded
|
23
|
+
created_at: 2003-07-26 12:38:10
|
24
|
+
updated_at: 2007-07-26 12:48:10
|
25
|
+
id: 1
|
26
|
+
|
27
|
+
"""
|
28
|
+
|
29
|
+
|
30
|
+
Scenario: rake db:load with different DUMP_PATH
|
31
|
+
Given a file named "db/alt/dump/users/schema.rb" with:
|
32
|
+
"""
|
33
|
+
create_table "users", :force => true do |t|
|
34
|
+
t.datetime "created_at"
|
35
|
+
t.datetime "updated_at"
|
36
|
+
t.string "name"
|
37
|
+
t.string "surname"
|
38
|
+
end
|
39
|
+
|
40
|
+
"""
|
41
|
+
And a file named "db/alt/dump/users/0000/0001.yml" with:
|
42
|
+
"""
|
43
|
+
---
|
44
|
+
name: Fred
|
45
|
+
created_at: 2002-07-23 12:28:10
|
46
|
+
updated_at: 2004-07-22 12:18:14
|
47
|
+
id: 1
|
48
|
+
surname: Bloggs
|
49
|
+
|
50
|
+
"""
|
51
|
+
When I successfully run `rake db:load FORCE=1 DUMP_PATH=db/alt/dump`
|
52
|
+
And I refresh the database tables cache
|
53
|
+
Then a "users" table should exist with structure:
|
54
|
+
| name | type |
|
55
|
+
| id | INTEGER |
|
56
|
+
| created_at | datetime |
|
57
|
+
| updated_at | datetime |
|
58
|
+
| name | varchar(255) |
|
59
|
+
| surname | varchar(255) |
|
60
|
+
And the "users" table should match exactly:
|
61
|
+
| id | name | surname | created_at | updated_at |
|
62
|
+
| 1 | Fred | Bloggs | 2002-07-23 12:28:10 | 2004-07-22 12:18:14 |
|
63
|
+
|
@@ -0,0 +1,103 @@
|
|
1
|
+
Feature: Load a database
|
2
|
+
In order to populate my database with the dumped structure (schema) and data (fixtures) in db/dump
|
3
|
+
I want an easy-to-use rake task to do the heavy lifting
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given I am in an empty app
|
7
|
+
And a Rakefile exists which has an environment task and loads git_friendly_dumper tasks
|
8
|
+
And an empty database
|
9
|
+
|
10
|
+
|
11
|
+
Scenario: rake db:load
|
12
|
+
Given a file named "db/dump/users/schema.rb" with:
|
13
|
+
"""
|
14
|
+
create_table "users", :force => true do |t|
|
15
|
+
t.datetime "created_at"
|
16
|
+
t.datetime "updated_at"
|
17
|
+
t.string "name"
|
18
|
+
t.string "surname"
|
19
|
+
end
|
20
|
+
|
21
|
+
"""
|
22
|
+
And a file named "db/dump/users/0000/0001.yml" with:
|
23
|
+
"""
|
24
|
+
---
|
25
|
+
name: Jane
|
26
|
+
created_at: 2003-07-26 12:38:10
|
27
|
+
updated_at: 2007-07-26 12:48:10
|
28
|
+
id: 1
|
29
|
+
surname: Heidie
|
30
|
+
|
31
|
+
"""
|
32
|
+
And a file named "db/dump/users/0001/0008.yml" with:
|
33
|
+
"""
|
34
|
+
---
|
35
|
+
name: Ethel
|
36
|
+
created_at: 2008-07-26 19:38:10
|
37
|
+
updated_at: 2010-03-22 11:38:10
|
38
|
+
id: 10008
|
39
|
+
surname: Smith
|
40
|
+
"""
|
41
|
+
|
42
|
+
And a file named "db/dump/debts/schema.rb" with:
|
43
|
+
"""
|
44
|
+
create_table "debts", :force => true do |t|
|
45
|
+
t.string "name"
|
46
|
+
t.integer "amount"
|
47
|
+
end
|
48
|
+
|
49
|
+
"""
|
50
|
+
And a file named "db/dump/debts/0000/0012.yml" with:
|
51
|
+
"""
|
52
|
+
---
|
53
|
+
name: Jane Heidie
|
54
|
+
id: 12
|
55
|
+
amount: 3403
|
56
|
+
|
57
|
+
"""
|
58
|
+
|
59
|
+
And a file named "db/dump/schema_migrations/schema.rb" with:
|
60
|
+
"""
|
61
|
+
create_table "schema_migrations", :force => true do |t|
|
62
|
+
t.string "version"
|
63
|
+
end
|
64
|
+
|
65
|
+
"""
|
66
|
+
And a file named "db/dump/schema_migrations/0000/0001.yml" with:
|
67
|
+
"""
|
68
|
+
---
|
69
|
+
version: "01001010123"
|
70
|
+
id: 1
|
71
|
+
|
72
|
+
"""
|
73
|
+
|
74
|
+
When I successfully run `rake db:load FORCE=1`
|
75
|
+
And I refresh the database tables cache
|
76
|
+
Then a "users" table should exist with structure:
|
77
|
+
| name | type |
|
78
|
+
| id | INTEGER |
|
79
|
+
| created_at | datetime |
|
80
|
+
| updated_at | datetime |
|
81
|
+
| name | varchar(255) |
|
82
|
+
| surname | varchar(255) |
|
83
|
+
And the "users" table should match exactly:
|
84
|
+
| id | name | surname | created_at | updated_at |
|
85
|
+
| 1 | Jane | Heidie | 2003-07-26 12:38:10 | 2007-07-26 12:48:10 |
|
86
|
+
| 10008 | Ethel | Smith | 2008-07-26 19:38:10 | 2010-03-22 11:38:10 |
|
87
|
+
|
88
|
+
And a "debts" table should exist with structure:
|
89
|
+
| name | type |
|
90
|
+
| id | INTEGER |
|
91
|
+
| name | varchar(255) |
|
92
|
+
| amount | integer |
|
93
|
+
And the "debts" table should match exactly:
|
94
|
+
| id | name | amount |
|
95
|
+
| 12 | Jane Heidie | 3403 |
|
96
|
+
|
97
|
+
And a "schema_migrations" table should exist with structure:
|
98
|
+
| name | type |
|
99
|
+
| id | INTEGER |
|
100
|
+
| version | varchar(255) |
|
101
|
+
And the "schema_migrations" table should match exactly:
|
102
|
+
| id | version |
|
103
|
+
| 1 | 01001010123 |
|
@@ -0,0 +1,97 @@
|
|
1
|
+
Feature: Toggle halting load when runtime errors occur
|
2
|
+
RAISE_ERROR=false|0 toggle halt on runtime errors (default true)
|
3
|
+
Useful for loading dev databases - don't use in production!
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given I am in an empty app
|
7
|
+
Given a Rakefile exists which has an environment task and loads git_friendly_dumper tasks
|
8
|
+
And an empty database
|
9
|
+
|
10
|
+
|
11
|
+
Scenario Outline: if a schema isn't found it always blows up, ignoring RAISE_ERROR
|
12
|
+
When I run `rake db:load FORCE=1 TABLES=doesnotexist RAISE_ERROR=<RAISE_ERROR>`
|
13
|
+
Then the exit status should be <EXIT_STATUS>
|
14
|
+
And the output should contain "No such file or directory"
|
15
|
+
|
16
|
+
Scenarios: always raises
|
17
|
+
| RAISE_ERROR | EXIT_STATUS |
|
18
|
+
| | 1 |
|
19
|
+
| false | 1 |
|
20
|
+
| 0 | 1 |
|
21
|
+
| true | 1 |
|
22
|
+
| 1 | 1 |
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
Scenario Outline: using RAISE_ERROR to toggle raising ActiveRecord insertion errors
|
27
|
+
Given a file named "db/dump/users/schema.rb" with:
|
28
|
+
"""
|
29
|
+
create_table "users", :force => true do |t|
|
30
|
+
t.datetime "created_at"
|
31
|
+
t.datetime "updated_at"
|
32
|
+
# t.string "name"
|
33
|
+
t.string "surname"
|
34
|
+
end
|
35
|
+
"""
|
36
|
+
And a file named "db/dump/users/0000/0001.yml" with:
|
37
|
+
"""
|
38
|
+
---
|
39
|
+
name: Jane
|
40
|
+
created_at: 2003-07-26 12:38:10
|
41
|
+
updated_at: 2007-07-26 12:48:10
|
42
|
+
id: 1
|
43
|
+
surname: Heidie
|
44
|
+
"""
|
45
|
+
|
46
|
+
When I run `rake db:load FORCE=1 TABLES=users RAISE_ERROR=<RAISE_ERROR>`
|
47
|
+
Then the exit status should be <EXIT_STATUS>
|
48
|
+
And the output <SEE_MESSAGE> contain "SQLite3::SQLException: table users has no column named name:"
|
49
|
+
|
50
|
+
Scenarios: don't raise
|
51
|
+
| RAISE_ERROR | EXIT_STATUS | SEE_MESSAGE |
|
52
|
+
| false | 0 | should not |
|
53
|
+
| 0 | 0 | should not |
|
54
|
+
|
55
|
+
Scenarios: raise
|
56
|
+
| RAISE_ERROR | EXIT_STATUS | SEE_MESSAGE |
|
57
|
+
| | 1 | should |
|
58
|
+
| true | 1 | should |
|
59
|
+
| 1 | 1 | should |
|
60
|
+
|
61
|
+
Scenario Outline: can also silence errors loading a fixture
|
62
|
+
Given a file named "db/dump/users/schema.rb" with:
|
63
|
+
"""
|
64
|
+
create_table "users", :force => true do |t|
|
65
|
+
t.datetime "created_at"
|
66
|
+
t.datetime "updated_at"
|
67
|
+
t.string "name"
|
68
|
+
t.string "surname"
|
69
|
+
end
|
70
|
+
"""
|
71
|
+
And I successfully run `rake db:load FORCE=1`
|
72
|
+
|
73
|
+
When I write to "db/dump/users/0000/0001.yml" with:
|
74
|
+
"""
|
75
|
+
---
|
76
|
+
forename: Jane
|
77
|
+
created_at: 2003-07-26 12:38:10
|
78
|
+
updated_at: 2007-07-26 12:48:10
|
79
|
+
id: 1
|
80
|
+
surname: Heidie
|
81
|
+
"""
|
82
|
+
And I run `rake db:data:load FORCE=1 FIXTURES='users/0000/0001.yml' RAISE_ERROR=<RAISE_ERROR>`
|
83
|
+
Then the exit status should be <EXIT_STATUS>
|
84
|
+
And the output <SEE_MESSAGE> contain "SQLite3::SQLException: table users has no column named forename:"
|
85
|
+
|
86
|
+
Scenarios: don't raise
|
87
|
+
| RAISE_ERROR | EXIT_STATUS | SEE_MESSAGE |
|
88
|
+
| false | 0 | should not |
|
89
|
+
| 0 | 0 | should not |
|
90
|
+
|
91
|
+
Scenarios: raise
|
92
|
+
| RAISE_ERROR | EXIT_STATUS | SEE_MESSAGE |
|
93
|
+
| | 1 | should |
|
94
|
+
| true | 1 | should |
|
95
|
+
| 1 | 1 | should |
|
96
|
+
|
97
|
+
|
@@ -0,0 +1,159 @@
|
|
1
|
+
Feature: Load fixtures
|
2
|
+
In order to load particular backups into my database
|
3
|
+
I want to pass the rake task a list of specific fixtures to be imported
|
4
|
+
FIXTURES -- specific fixture files to load, invalid argument for dump tasks
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given I am in an empty app
|
8
|
+
And a Rakefile exists which has an environment task and loads git_friendly_dumper tasks
|
9
|
+
And an empty database
|
10
|
+
And the database has a "users" table:
|
11
|
+
| name (string) | surname (string) |
|
12
|
+
| Fred | Bloggs |
|
13
|
+
| Ethel | Smith |
|
14
|
+
| Jane | Heidie |
|
15
|
+
And a file named "db/dump/users/0000/0001.yml" with:
|
16
|
+
"""
|
17
|
+
---
|
18
|
+
name: Frodo
|
19
|
+
id: 1
|
20
|
+
surname: Bloggo
|
21
|
+
"""
|
22
|
+
And a file named "db/dump/users/0000/0002.yml" with:
|
23
|
+
"""
|
24
|
+
---
|
25
|
+
name: Ethelene
|
26
|
+
id: 2
|
27
|
+
surname: Smithy
|
28
|
+
"""
|
29
|
+
|
30
|
+
|
31
|
+
Scenario: can't use rake db:load FIXTURES=…
|
32
|
+
When I run `rake db:load FIXTURES=users/0000/0001.yml FORCE=true`
|
33
|
+
Then the exit status should be 1
|
34
|
+
And the "users" table should match exactly:
|
35
|
+
| id | name | surname |
|
36
|
+
| 1 | Fred | Bloggs |
|
37
|
+
| 2 | Ethel | Smith |
|
38
|
+
| 3 | Jane | Heidie |
|
39
|
+
And the output should contain "if :fixtures option given, neither :include_schema nor :clobber_fixtures"
|
40
|
+
|
41
|
+
|
42
|
+
Scenario: can't use rake db:data:load FIXTURES=… CLOBBER_FIXTURES=true
|
43
|
+
When I run `rake db:load FIXTURES=users/0000/0001.yml CLOBBER_FIXTURES=true FORCE=true`
|
44
|
+
Then the exit status should be 1
|
45
|
+
And the output should contain "if :fixtures option given, neither :include_schema nor :clobber_fixtures"
|
46
|
+
|
47
|
+
|
48
|
+
Scenario: trying to load with FIXTURES and FIXTURES_FILE should raise an error
|
49
|
+
When I run `rake db:data:load FIXTURES_FILE=foo FIXTURES=notes/0000/0001.yml FORCE=true`
|
50
|
+
Then the exit status should be 1
|
51
|
+
And the output should contain "GitFriendlyDumper cannot specify both :fixtures and :fixtures_file"
|
52
|
+
|
53
|
+
|
54
|
+
Scenario: loading specific fixtures into an existing table with records only replaces the ones I specify
|
55
|
+
When I successfully run `rake db:data:load FIXTURES=users/0000/0001.yml FORCE=true`
|
56
|
+
And the "users" table should match exactly:
|
57
|
+
| id | name | surname |
|
58
|
+
| 1 | Frodo | Bloggo |
|
59
|
+
| 2 | Ethel | Smith |
|
60
|
+
| 3 | Jane | Heidie |
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
Scenario: loading a fixture which does not exist deletes its record
|
65
|
+
When I successfully run `rake db:data:load FIXTURES=users/0000/0003.yml FORCE=true`
|
66
|
+
And the "users" table should match exactly:
|
67
|
+
| id | name | surname |
|
68
|
+
| 1 | Fred | Bloggs |
|
69
|
+
| 2 | Ethel | Smith |
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
Scenario: inserting a non-existant record from fixture
|
75
|
+
Given a file named "db/dump/users/0000/0011.yml" with:
|
76
|
+
"""
|
77
|
+
---
|
78
|
+
name: Bob
|
79
|
+
id: 11
|
80
|
+
surname: Smith
|
81
|
+
"""
|
82
|
+
|
83
|
+
When I successfully run `rake db:data:load FIXTURES=users/0000/0011.yml FORCE=true`
|
84
|
+
And the "users" table should match exactly:
|
85
|
+
| id | name | surname |
|
86
|
+
| 1 | Fred | Bloggs |
|
87
|
+
| 2 | Ethel | Smith |
|
88
|
+
| 3 | Jane | Heidie |
|
89
|
+
| 11 | Bob | Smith |
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
Scenario: Updating, Creating & Deleting all in one go
|
94
|
+
Given a file named "db/dump/users/0000/0011.yml" with:
|
95
|
+
"""
|
96
|
+
---
|
97
|
+
name: Bob
|
98
|
+
id: 11
|
99
|
+
surname: Smith
|
100
|
+
"""
|
101
|
+
|
102
|
+
When I successfully run `rake db:data:load FIXTURES=users/0000/0001.yml,users/0000/0003.yml,users/0000/0011.yml FORCE=true`
|
103
|
+
And the "users" table should match exactly:
|
104
|
+
| id | name | surname |
|
105
|
+
| 1 | Frodo | Bloggo |
|
106
|
+
| 2 | Ethel | Smith |
|
107
|
+
| 11 | Bob | Smith |
|
108
|
+
|
109
|
+
|
110
|
+
Scenario: specifying fixtures via a fixtures_file
|
111
|
+
Given a file named "db/dump/users/0000/0011.yml" with:
|
112
|
+
"""
|
113
|
+
---
|
114
|
+
name: Bob
|
115
|
+
id: 11
|
116
|
+
surname: Smith
|
117
|
+
"""
|
118
|
+
|
119
|
+
And a file named "db/dump/fixtures" with:
|
120
|
+
"""
|
121
|
+
users/0000/0001.yml
|
122
|
+
users/0000/0003.yml
|
123
|
+
users/0000/0011.yml
|
124
|
+
"""
|
125
|
+
|
126
|
+
When I successfully run `rake db:data:load FIXTURES_FILE=db/dump/fixtures FORCE=true`
|
127
|
+
Then the "users" table should match exactly:
|
128
|
+
| id | name | surname |
|
129
|
+
| 1 | Frodo | Bloggo |
|
130
|
+
| 2 | Ethel | Smith |
|
131
|
+
| 11 | Bob | Smith |
|
132
|
+
|
133
|
+
|
134
|
+
Scenario: TABLES can be used whitelist a subset of the FIXTURES to operate on
|
135
|
+
Given the database has a "notes" table:
|
136
|
+
| body (string) |
|
137
|
+
| Get milk |
|
138
|
+
| Buy Meat |
|
139
|
+
And a file named "db/dump/notes/0000/0001.yml" with:
|
140
|
+
"""
|
141
|
+
---
|
142
|
+
body: Get cheese
|
143
|
+
id: 1
|
144
|
+
"""
|
145
|
+
|
146
|
+
When I successfully run `rake db:data:load TABLES=notes FIXTURES=notes/0000/0001.yml,users/0000/0001.yml,users/0000/0003.yml,users/0000/0011.yml FORCE=true`
|
147
|
+
Then the "notes" table should match exactly:
|
148
|
+
| id | body |
|
149
|
+
| 1 | Get cheese |
|
150
|
+
| 2 | Buy Meat |
|
151
|
+
And the "users" table should match exactly:
|
152
|
+
| id | name | surname |
|
153
|
+
| 1 | Fred | Bloggs |
|
154
|
+
| 2 | Ethel | Smith |
|
155
|
+
| 3 | Jane | Heidie |
|
156
|
+
|
157
|
+
|
158
|
+
Scenario: FIXTURES should be able to be specified as a file, instead of an env var
|
159
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Feature: Figure out git changes since last load
|
2
|
+
In order to speed up loading, when using a git based dump
|
3
|
+
I want to be able to load fixtures changes since last load
|
4
|
+
|
5
|
+
Scenario: rake db:data:load SINCE_REF=<git ref> loads fixtures since then
|
6
|
+
|
7
|
+
Scenario: rake db:data:load SINCE_REF=<git ref> borks if DUMP_PATH aint a git repo
|
8
|
+
|
9
|
+
Scenario: rake db:data:load SINCE_LAST_LOAD=true loads fixtures since last load
|
10
|
+
|
11
|
+
Scenario: rake db:data:load SINCE_LAST_LOAD=true borks if no last_load_ref exists in DUMP_PATH
|
12
|
+
|
13
|
+
Scenario: rake db:data:load creates a last_load_ref in DUMP_PATH
|
14
|
+
|
15
|
+
Scenario: rake db:data:load WRITE_LAST_LOAD_REF=false doesn't create a last_load_ref
|
16
|
+
|
17
|
+
|
@@ -0,0 +1,119 @@
|
|
1
|
+
Feature: Load specific tables
|
2
|
+
In order to only restore particular tables from the dump to my database
|
3
|
+
I want to specify a list of table names for the rake task to process
|
4
|
+
TABLES=comma,sep,list tables to dump/load (default all)
|
5
|
+
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given I am in an empty app
|
9
|
+
And a Rakefile exists which has an environment task and loads git_friendly_dumper tasks
|
10
|
+
And an empty database
|
11
|
+
|
12
|
+
Given a file named "db/dump/users/schema.rb" with:
|
13
|
+
"""
|
14
|
+
create_table "users", :force => true do |t|
|
15
|
+
t.datetime "created_at"
|
16
|
+
t.datetime "updated_at"
|
17
|
+
t.string "name"
|
18
|
+
t.string "surname"
|
19
|
+
end
|
20
|
+
|
21
|
+
"""
|
22
|
+
And a file named "db/dump/users/0000/0001.yml" with:
|
23
|
+
"""
|
24
|
+
---
|
25
|
+
name: Jane
|
26
|
+
created_at: 2003-07-26 12:38:10
|
27
|
+
updated_at: 2007-07-26 12:48:10
|
28
|
+
id: 1
|
29
|
+
surname: Heidie
|
30
|
+
|
31
|
+
"""
|
32
|
+
And a file named "db/dump/users/0001/0008.yml" with:
|
33
|
+
"""
|
34
|
+
---
|
35
|
+
name: Ethel
|
36
|
+
created_at: 2008-07-26 19:38:10
|
37
|
+
updated_at: 2010-03-22 11:38:10
|
38
|
+
id: 10008
|
39
|
+
surname: Smith
|
40
|
+
"""
|
41
|
+
|
42
|
+
And a file named "db/dump/debts/schema.rb" with:
|
43
|
+
"""
|
44
|
+
create_table "debts", :force => true do |t|
|
45
|
+
t.string "name"
|
46
|
+
t.integer "amount"
|
47
|
+
end
|
48
|
+
|
49
|
+
"""
|
50
|
+
And a file named "db/dump/debts/0000/0012.yml" with:
|
51
|
+
"""
|
52
|
+
---
|
53
|
+
name: Jane Heidie
|
54
|
+
id: 12
|
55
|
+
amount: 3403
|
56
|
+
|
57
|
+
"""
|
58
|
+
|
59
|
+
And a file named "db/dump/schema_migrations/schema.rb" with:
|
60
|
+
"""
|
61
|
+
create_table "schema_migrations", :force => true do |t|
|
62
|
+
t.string "version"
|
63
|
+
end
|
64
|
+
|
65
|
+
"""
|
66
|
+
And a file named "db/dump/schema_migrations/0000/0001.yml" with:
|
67
|
+
"""
|
68
|
+
---
|
69
|
+
version: "01001010123"
|
70
|
+
id: 1
|
71
|
+
|
72
|
+
"""
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
Scenario: load the debts table only
|
77
|
+
When I successfully run `rake db:load FORCE=1 TABLES=debts`
|
78
|
+
Then the database should have tables:
|
79
|
+
| debts |
|
80
|
+
But the database should not have table "users"
|
81
|
+
But the database should not have table "schema_migrations"
|
82
|
+
And a "debts" table should exist with structure:
|
83
|
+
| name | type |
|
84
|
+
| id | INTEGER |
|
85
|
+
| name | varchar(255) |
|
86
|
+
| amount | integer |
|
87
|
+
And the "debts" table should match exactly:
|
88
|
+
| id | name | amount |
|
89
|
+
| 12 | Jane Heidie | 3403 |
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
Scenario: load the users and debts tables
|
94
|
+
When I successfully run `rake db:load FORCE=1 TABLES=debts,users`
|
95
|
+
Then the database should have tables:
|
96
|
+
| debts |
|
97
|
+
| users |
|
98
|
+
But the database should not have table "schema_migrations"
|
99
|
+
|
100
|
+
Then a "users" table should exist with structure:
|
101
|
+
| name | type |
|
102
|
+
| id | INTEGER |
|
103
|
+
| created_at | datetime |
|
104
|
+
| updated_at | datetime |
|
105
|
+
| name | varchar(255) |
|
106
|
+
| surname | varchar(255) |
|
107
|
+
And the "users" table should match exactly:
|
108
|
+
| id | name | surname | created_at | updated_at |
|
109
|
+
| 1 | Jane | Heidie | 2003-07-26 12:38:10 | 2007-07-26 12:48:10 |
|
110
|
+
| 10008 | Ethel | Smith | 2008-07-26 19:38:10 | 2010-03-22 11:38:10 |
|
111
|
+
|
112
|
+
And a "debts" table should exist with structure:
|
113
|
+
| name | type |
|
114
|
+
| id | INTEGER |
|
115
|
+
| name | varchar(255) |
|
116
|
+
| amount | integer |
|
117
|
+
And the "debts" table should match exactly:
|
118
|
+
| id | name | amount |
|
119
|
+
| 12 | Jane Heidie | 3403 |
|