Skip to content

Commit

Permalink
Build, dumping and restoring geodata.
Browse files Browse the repository at this point in the history
  • Loading branch information
TuckerJD committed May 27, 2014
1 parent 8060416 commit d79fc88
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
1 change: 0 additions & 1 deletion app/models/geographic_area.rb
Expand Up @@ -50,7 +50,6 @@ class GeographicArea < ActiveRecord::Base

validates_presence_of :data_origin
validates :name, presence: true, length: { minimum: 1 }
validates_uniqueness_of :name, scope: [:level0, :level1, :level2] unless ENV['NO_GEO_VALID']

scope :descendants_of, -> (geographic_area) {
where('(geographic_areas.lft >= ?) and (geographic_areas.lft <= ?) and
Expand Down
26 changes: 5 additions & 21 deletions lib/tasks/initialization/geographic_areas.rake
Expand Up @@ -12,36 +12,20 @@
2: rake tw:development:data:geo:build_geographic_areas data_directory=$HOME/src/gaz/ user_id=1 database_role=taxonworks_development NO_GEO_NESTING=1 NO_GEO_VALID=1
3: rake tw:development:data:geo:rebuild_geographic_areas_nesting # TODO: @jdt fix this
3: rake tw:development:data:geo:build_geographic_items_from_temporary_shape_tables data_directory=/Users/tuckerjd/src/gaz/ database_role=taxonworks_development user_id=1
4. rake tw:export:geo:pg_dump_geo_data[$HOME/src/gaz/data/internal/dump/]
alt:
a: rake tw:export:table table_name=geographic_area_types > ../gaz/data/internal/csv/geographic_area_types.csv
b: rake tw:export:table table_name=geographic_areas > ../gaz/data/internal/csv/geographic_areas.csv
c: rake tw:export:table table_name=geographic_items > ../gaz/data/internal/csv/geographic_items.csv
d: rake tw:export:table table_name=geographic_items > ../gaz/data/internal/csv/geographic_items.csv
4: rake tw:development:data:geo:rebuild_geographic_areas_nesting
(Reloading)
1: rake db:setup
1: rake db:drop RAILS_ENV=development && rake db:create RAILS_ENV=development && rake db:migrate RAILS_ENV=development && rake db:seed RAILS_ENV=development
(Make sure that there are no processes connected to the development data base, including (but not limited to:
pgAdmin
psql
RubyMine))
2. rake tw:initialization:restore_geo_data[../gaz/data/internal/dump/]
Alternately, load them individually:
a: rake tw:initialization:load_geographic_area_types[../gaz/data/internal/csv/geographic_area_types.csv]
b: rake tw:initialization:load_geographic_items[../gaz/data/internal/csv/geographic_items.csv]
c: rake tw:initialization:load_geographic_areas[../gaz/data/internal/csv/geographic_areas.csv] NO_GEO_NESTING=1
2. rake tw:initialization:restore_geo_data_from_pg_dump data_directory=/Users/tuckerjd/src/gaz/data/internal/dump/
11: rake tw:init:rebuild_geographic_areas_nesting
3: rake tw:development:data:geo:rebuild_geographic_areas_nesting
=end

Expand Down

0 comments on commit d79fc88

Please sign in to comment.