db_reference 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +28 -3
- data/Rakefile +1 -1
- metadata +3 -3
data/README
CHANGED
@@ -1,13 +1,38 @@
|
|
1
1
|
Reference
|
2
2
|
=========
|
3
3
|
|
4
|
-
|
4
|
+
Used for creating a predefined set of models, similar to db:seed, but will not repopulate if entries already exist.
|
5
5
|
|
6
|
+
Place references in 'db/reference/'
|
7
|
+
References will be loaded in ascending order, so if an order is desired, prepend 000, 001, 002... etc to the filename.
|
8
|
+
|
9
|
+
Run with:
|
10
|
+
rake reference:load
|
6
11
|
|
7
12
|
Example
|
8
13
|
=======
|
9
14
|
|
10
|
-
|
15
|
+
The below example ensures that there are 6 locations existing in the database after running the 'rake reference:load'
|
16
|
+
|
17
|
+
|
18
|
+
# db/schema.rb
|
19
|
+
create_table "locations", :force => true do |t|
|
20
|
+
t.string "name", :null => false
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
# db/reference/000_locations.rb
|
25
|
+
Location.update_or_create :id => 1, :name => 'Wellington City'
|
26
|
+
Location.update_or_create :id => 2, :name => 'Lower Hutt'
|
27
|
+
Location.update_or_create :id => 3, :name => 'Kapiti Coast'
|
28
|
+
Location.update_or_create :id => 4, :name => 'Porirua'
|
29
|
+
Location.update_or_create :id => 5, :name => 'Upper Hutt'
|
30
|
+
Location.update_or_create :id => 6, :name => 'Wairarapa'
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
11
36
|
|
12
37
|
|
13
|
-
Copyright (c) 2010
|
38
|
+
Copyright (c) 2010 Able Technology, released under the MIT license
|
data/Rakefile
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: db_reference
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Cam Fowler
|