erp_work_effort 3.0.4 → 3.1.0
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/app/models/cost.rb +2 -0
- data/app/models/party_resource_availability.rb +2 -0
- data/app/models/party_resource_availability_type.rb +2 -0
- data/app/models/valid_work_assignment.rb +2 -0
- data/app/models/valid_work_assignment_attribute.rb +2 -0
- data/app/models/work_effort.rb +2 -0
- data/app/models/work_effort_assignment.rb +2 -0
- data/app/models/work_effort_status.rb +2 -0
- data/app/models/work_effort_status_type.rb +2 -0
- data/app/models/work_requirement.rb +2 -0
- data/app/models/work_requirement_work_effort_status_type.rb +2 -0
- data/lib/erp_work_effort.rb +2 -0
- data/lib/erp_work_effort/version.rb +2 -2
- data/spec/dummy/config/application.rb +6 -0
- data/spec/dummy/config/environments/spec.rb +3 -0
- data/spec/dummy/db/data_migrations/20110109173616_create_capability_scope_types.erp_tech_svcs.rb +15 -0
- data/spec/dummy/db/data_migrations/20110525001935_add_usd_currency.erp_base_erp_svcs.rb +12 -0
- data/spec/dummy/db/data_migrations/20110609150135_add_iso_codes.erp_base_erp_svcs.rb +19 -0
- data/spec/dummy/db/data_migrations/20110802200222_schedule_delete_expired_sessions_job.erp_tech_svcs.rb +16 -0
- data/spec/dummy/db/data_migrations/20110913145838_setup_compass_ae_instance.erp_base_erp_svcs.rb +12 -0
- data/spec/dummy/db/data_migrations/20111111144706_setup_audit_log_types.erp_tech_svcs.rb +22 -0
- data/spec/dummy/db/data_migrations/20120109173616_create_download_capability_type.erp_tech_svcs.rb +14 -0
- data/spec/dummy/db/data_migrations/20121116155018_create_group_relationship_and_role_types.erp_tech_svcs.rb +20 -0
- data/spec/dummy/db/data_migrations/20121130212146_note_capabilities.erp_tech_svcs.rb +24 -0
- data/spec/dummy/db/migrate/20121219191143_base_erp_services.erp_base_erp_svcs.rb +461 -0
- data/spec/dummy/db/migrate/20121219191144_base_work_efforts.erp_work_effort.rb +211 -0
- data/spec/dummy/db/migrate/20121219191145_base_tech_services.erp_tech_svcs.rb +255 -0
- data/spec/dummy/db/migrate/20121219191146_create_has_attribute_tables.erp_tech_svcs.rb +39 -0
- data/spec/dummy/db/migrate/20130107180754_create_groups.erp_tech_svcs.rb +19 -0
- data/spec/dummy/db/migrate/20130107180755_upgrade_security.erp_tech_svcs.rb +54 -0
- data/spec/dummy/db/migrate/20130107180756_upgrade_security2.erp_tech_svcs.rb +270 -0
- data/spec/dummy/db/schema.rb +735 -0
- data/spec/dummy/db/spec.sqlite3 +0 -0
- data/spec/dummy/log/spec.log +6311 -0
- data/spec/spec_helper.rb +11 -3
- metadata +63 -10
- data/db/migrate/upgrade/20111216190747_add_work_effort_to_work_effort_assignment.rb +0 -13
    
        data/app/models/cost.rb
    CHANGED
    
    
    
        data/app/models/work_effort.rb
    CHANGED
    
    
| @@ -1,4 +1,6 @@ | |
| 1 1 | 
             
            class WorkEffortStatusType < ActiveRecord::Base
         | 
| 2 | 
            +
              attr_protected :created_at, :updated_at
         | 
| 3 | 
            +
             | 
| 2 4 | 
             
              has_many   :work_effort_statuses
         | 
| 3 5 | 
             
              has_one    :previous_status_type, :class_name => 'WorkEffortStatusType', :foreign_key => 'previous_status_id'
         | 
| 4 6 | 
             
              has_one    :next_status_type, :class_name => 'WorkEffortStatusType', :foreign_key => 'next_status_id'
         | 
    
        data/lib/erp_work_effort.rb
    CHANGED
    
    
| @@ -38,6 +38,12 @@ module Dummy | |
| 38 38 |  | 
| 39 39 | 
             
                # Enable the asset pipeline
         | 
| 40 40 | 
             
                config.assets.enabled = true
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                # Enforce whitelist mode for mass assignment.
         | 
| 43 | 
            +
                # This will create an empty whitelist of attributes available for mass-assignment for all models
         | 
| 44 | 
            +
                # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
         | 
| 45 | 
            +
                # parameters by using an attr_accessible or attr_protected declaration.
         | 
| 46 | 
            +
                config.active_record.whitelist_attributes = true    
         | 
| 41 47 | 
             
              end
         | 
| 42 48 | 
             
            end
         | 
| 43 49 |  | 
| @@ -1,6 +1,9 @@ | |
| 1 1 | 
             
            Dummy::Application.configure do
         | 
| 2 2 | 
             
              # Settings specified here will take precedence over those in config/application.rb
         | 
| 3 3 |  | 
| 4 | 
            +
              # Raise exception on mass assignment protection for Active Record models
         | 
| 5 | 
            +
              config.active_record.mass_assignment_sanitizer = :strict
         | 
| 6 | 
            +
             | 
| 4 7 | 
             
              # In the development environment your application's code is reloaded on
         | 
| 5 8 | 
             
              # every request.  This slows down response time but is perfect for development
         | 
| 6 9 | 
             
              # since you don't have to restart the web server when you make code changes.
         | 
    
        data/spec/dummy/db/data_migrations/20110109173616_create_capability_scope_types.erp_tech_svcs.rb
    ADDED
    
    | @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            # This migration comes from erp_tech_svcs (originally 20110109173616)
         | 
| 2 | 
            +
            class CreateCapabilityScopeTypes
         | 
| 3 | 
            +
              
         | 
| 4 | 
            +
              def self.up
         | 
| 5 | 
            +
                CapabilityType.create(:internal_identifier => 'download', :description => 'Download') if CapabilityType.where("internal_identifier = 'download'").first.nil?
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                ScopeType.create(:description => 'Instance', :internal_identifier => 'instance') if ScopeType.where("internal_identifier = 'instance'").first.nil?
         | 
| 8 | 
            +
                ScopeType.create(:description => 'Class', :internal_identifier => 'class') if ScopeType.where("internal_identifier = 'class'").first.nil?
         | 
| 9 | 
            +
                ScopeType.create(:description => 'Query', :internal_identifier => 'query') if ScopeType.where("internal_identifier = 'query'").first.nil?
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
              
         | 
| 12 | 
            +
              def self.down
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            end
         | 
| @@ -0,0 +1,12 @@ | |
| 1 | 
            +
            # This migration comes from erp_base_erp_svcs (originally 20110525001935)
         | 
| 2 | 
            +
            class AddUsdCurrency
         | 
| 3 | 
            +
              
         | 
| 4 | 
            +
              def self.up
         | 
| 5 | 
            +
                Currency.create(:name => 'US Dollar', :internal_identifier => 'USD', :major_unit_symbol => "$")
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
              
         | 
| 8 | 
            +
              def self.down
         | 
| 9 | 
            +
                Currency.usd.destroy
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            end
         | 
| @@ -0,0 +1,19 @@ | |
| 1 | 
            +
            # This migration comes from erp_base_erp_svcs (originally 20110609150135)
         | 
| 2 | 
            +
            require 'yaml'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            class AddIsoCodes
         | 
| 5 | 
            +
              
         | 
| 6 | 
            +
              def self.up
         | 
| 7 | 
            +
                #find the erp_base_erp_svcs engine
         | 
| 8 | 
            +
            	  engine_path = Rails::Application::Railties.engines.find{|item| item.engine_name == 'erp_base_erp_svcs'}.config.root.to_s
         | 
| 9 | 
            +
            	
         | 
| 10 | 
            +
            	  GeoCountry.load_from_file(File.join(engine_path,'db/data_sets/geo_countries.yml'))
         | 
| 11 | 
            +
                GeoZone.load_from_file(File.join(engine_path,'db/data_sets/geo_zones.yml'))
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
              
         | 
| 14 | 
            +
              def self.down
         | 
| 15 | 
            +
                GeoCountry.delete_all
         | 
| 16 | 
            +
                GeoZone.delete_all
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            end
         | 
| @@ -0,0 +1,16 @@ | |
| 1 | 
            +
            # This migration comes from erp_tech_svcs (originally 20110802200222)
         | 
| 2 | 
            +
            class ScheduleDeleteExpiredSessionsJob
         | 
| 3 | 
            +
              
         | 
| 4 | 
            +
              def self.up
         | 
| 5 | 
            +
                #insert data here
         | 
| 6 | 
            +
                date = Date.tomorrow
         | 
| 7 | 
            +
                start_time = DateTime.civil(date.year, date.month, date.day, 2, 0, 1, -(5.0/24.0))
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                ErpTechSvcs::Sessions::DeleteExpiredSessionsJob.schedule_job(start_time)
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
              
         | 
| 12 | 
            +
              def self.down
         | 
| 13 | 
            +
                #remove data here
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            end
         | 
| @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            # This migration comes from erp_tech_svcs (originally 20111111144706)
         | 
| 2 | 
            +
            class SetupAuditLogTypes
         | 
| 3 | 
            +
              
         | 
| 4 | 
            +
              def self.up
         | 
| 5 | 
            +
                application_alt = AuditLogType.create(:description => 'Application', :internal_identifier => 'application')
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                [
         | 
| 8 | 
            +
                  {:description => 'Custom Message', :internal_identifier => 'custom_message'},
         | 
| 9 | 
            +
                  {:description => 'Successful Logout', :internal_identifier => 'successful_logout'},
         | 
| 10 | 
            +
                  {:description => 'Successful Login', :internal_identifier => 'successful_login'},
         | 
| 11 | 
            +
                  {:description => 'Accessed Area', :internal_identifier => 'accessed_area'},
         | 
| 12 | 
            +
                  {:description => 'Session Timeout', :internal_identifier => 'session_timeout'}
         | 
| 13 | 
            +
                ].each do |alt_hash|
         | 
| 14 | 
            +
                    AuditLogType.create(alt_hash).move_to_child_of(application_alt)
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
              
         | 
| 18 | 
            +
              def self.down
         | 
| 19 | 
            +
                AuditLogType.destroy_all
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            end
         | 
    
        data/spec/dummy/db/data_migrations/20120109173616_create_download_capability_type.erp_tech_svcs.rb
    ADDED
    
    | @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            # This migration comes from erp_tech_svcs (originally 20120109173616)
         | 
| 2 | 
            +
            class CreateDownloadCapabilityType
         | 
| 3 | 
            +
              
         | 
| 4 | 
            +
              def self.up
         | 
| 5 | 
            +
                CapabilityType.create(:internal_identifier => 'download', :description => 'Download')
         | 
| 6 | 
            +
                Role.create(:description => 'File Downloader', :internal_identifier => 'file_downloader')
         | 
| 7 | 
            +
              end
         | 
| 8 | 
            +
              
         | 
| 9 | 
            +
              def self.down
         | 
| 10 | 
            +
                CapabilityType.where("internal_identifier = 'download'").first.destroy unless Role.where("internal_identifier = 'download'").first.nil?
         | 
| 11 | 
            +
                Role.where("internal_identifier = 'file_downloader'").first.destroy  unless Role.where("internal_identifier = 'file_downloader'").first.nil?
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            end
         | 
| @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            # This migration comes from erp_tech_svcs (originally 20121116155018)
         | 
| 2 | 
            +
            class CreateGroupRelationshipAndRoleTypes
         | 
| 3 | 
            +
              
         | 
| 4 | 
            +
              def self.up
         | 
| 5 | 
            +
                #insert data here
         | 
| 6 | 
            +
                to_role = RoleType.create(:description => 'Security Group', :internal_identifier => 'group')
         | 
| 7 | 
            +
                from_role = RoleType.create(:description => 'Security Group Member', :internal_identifier => 'group_member')
         | 
| 8 | 
            +
                RelationshipType.create(:description => 'Security Group Membership', 
         | 
| 9 | 
            +
                                        :name => 'Group Membership', 
         | 
| 10 | 
            +
                                        :internal_identifier => 'group_membership',
         | 
| 11 | 
            +
                                        :valid_from_role => from_role,
         | 
| 12 | 
            +
                                        :valid_to_role => to_role
         | 
| 13 | 
            +
                                      )
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
              
         | 
| 16 | 
            +
              def self.down
         | 
| 17 | 
            +
                #remove data here
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            end
         | 
| @@ -0,0 +1,24 @@ | |
| 1 | 
            +
            # This migration comes from erp_tech_svcs (originally 20121130212146)
         | 
| 2 | 
            +
            class NoteCapabilities
         | 
| 3 | 
            +
              
         | 
| 4 | 
            +
              def self.up
         | 
| 5 | 
            +
                #insert data here
         | 
| 6 | 
            +
                admin = SecurityRole.find_or_create_by_description_and_internal_identifier(:description => 'Admin', :internal_identifier => 'admin')
         | 
| 7 | 
            +
                employee = SecurityRole.find_or_create_by_description_and_internal_identifier(:description => 'Employee', :internal_identifier => 'employee')
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                admin.add_capability('create', 'Note')
         | 
| 10 | 
            +
                admin.add_capability('delete', 'Note')
         | 
| 11 | 
            +
                admin.add_capability('edit', 'Note')
         | 
| 12 | 
            +
                admin.add_capability('view', 'Note')
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                employee.add_capability('create', 'Note')
         | 
| 15 | 
            +
                employee.add_capability('delete', 'Note')
         | 
| 16 | 
            +
                employee.add_capability('edit', 'Note')
         | 
| 17 | 
            +
                employee.add_capability('view', 'Note')
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
              
         | 
| 20 | 
            +
              def self.down
         | 
| 21 | 
            +
                #remove data here
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            end
         | 
| @@ -0,0 +1,461 @@ | |
| 1 | 
            +
            # This migration comes from erp_base_erp_svcs (originally 20080805000020)
         | 
| 2 | 
            +
            class BaseErpServices < ActiveRecord::Migration
         | 
| 3 | 
            +
              def self.up
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                unless table_exists?(:compass_ae_instances)
         | 
| 6 | 
            +
                  create_table :compass_ae_instances do |t|
         | 
| 7 | 
            +
                    t.decimal :version, :scale => 8, :precision => 3
         | 
| 8 | 
            +
                    
         | 
| 9 | 
            +
                    t.timestamps
         | 
| 10 | 
            +
                  end
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                # Create parties table
         | 
| 14 | 
            +
                unless table_exists?(:parties)
         | 
| 15 | 
            +
                  create_table :parties do |t|
         | 
| 16 | 
            +
                    t.column :description, :string
         | 
| 17 | 
            +
                    t.column :business_party_id, :integer
         | 
| 18 | 
            +
                    t.column :business_party_type, :string
         | 
| 19 | 
            +
                    t.column :list_view_image_id, :integer
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                    #This field is here to provide a direct way to map CompassERP
         | 
| 22 | 
            +
                    #business parties to unified idenfiers in organizations if they
         | 
| 23 | 
            +
                    #have been implemented in an enterprise.
         | 
| 24 | 
            +
                    t.column :enterprise_identifier, :string
         | 
| 25 | 
            +
                    t.timestamps
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
                  add_index :parties, [:business_party_id, :business_party_type], :name => "besi_1"
         | 
| 28 | 
            +
                end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                # Create party_roles table
         | 
| 31 | 
            +
                unless table_exists?(:party_roles)
         | 
| 32 | 
            +
                  create_table :party_roles do |t|
         | 
| 33 | 
            +
                    #this column holds the class name of the 
         | 
| 34 | 
            +
                    #subtype of party-to-role_type relatsionship
         | 
| 35 | 
            +
                    t.column :type, :string
         | 
| 36 | 
            +
                    #xref between party and role_type      
         | 
| 37 | 
            +
                    t.column :party_id, :integer
         | 
| 38 | 
            +
                    t.column :role_type_id, :integer
         | 
| 39 | 
            +
                    t.timestamps
         | 
| 40 | 
            +
                  end
         | 
| 41 | 
            +
                  add_index :party_roles, :party_id
         | 
| 42 | 
            +
                  add_index :party_roles, :role_type_id
         | 
| 43 | 
            +
                end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
             | 
| 46 | 
            +
                # Create role_types table
         | 
| 47 | 
            +
                unless table_exists?(:role_types)
         | 
| 48 | 
            +
                  create_table :role_types do |t|
         | 
| 49 | 
            +
                    #these columns are required to support the behavior of the plugin 'awesome_nested_set'
         | 
| 50 | 
            +
                    t.column :parent_id, :integer
         | 
| 51 | 
            +
                    t.column :lft, :integer
         | 
| 52 | 
            +
                    t.column :rgt, :integer
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                    #custom columns go here   
         | 
| 55 | 
            +
                    t.column :description, :string
         | 
| 56 | 
            +
                    t.column :comments, :string
         | 
| 57 | 
            +
                    t.column :internal_identifier, :string
         | 
| 58 | 
            +
                    t.column :external_identifier, :string
         | 
| 59 | 
            +
                    t.column :external_id_source, :string
         | 
| 60 | 
            +
                    t.timestamps
         | 
| 61 | 
            +
                  end
         | 
| 62 | 
            +
                end
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                # Create relationship_types table
         | 
| 65 | 
            +
                unless table_exists?(:relationship_types)
         | 
| 66 | 
            +
                  create_table :relationship_types do |t|
         | 
| 67 | 
            +
                    t.column :parent_id, :integer
         | 
| 68 | 
            +
                    t.column :lft, :integer
         | 
| 69 | 
            +
                    t.column :rgt, :integer
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                    #custom columns go here        
         | 
| 72 | 
            +
                    t.column :valid_from_role_type_id, :integer
         | 
| 73 | 
            +
                    t.column :valid_to_role_type_id, :integer
         | 
| 74 | 
            +
                    t.column :name, :string
         | 
| 75 | 
            +
                    t.column :description, :string
         | 
| 76 | 
            +
             | 
| 77 | 
            +
                    t.column :internal_identifier, :string
         | 
| 78 | 
            +
                    t.column :external_identifier, :string
         | 
| 79 | 
            +
                    t.column :external_id_source, :string
         | 
| 80 | 
            +
                    t.timestamps
         | 
| 81 | 
            +
                  end
         | 
| 82 | 
            +
                  add_index :relationship_types, :valid_from_role_type_id
         | 
| 83 | 
            +
                  add_index :relationship_types, :valid_to_role_type_id
         | 
| 84 | 
            +
                end
         | 
| 85 | 
            +
             | 
| 86 | 
            +
                # Create party_relationships table
         | 
| 87 | 
            +
                unless table_exists?(:party_relationships)
         | 
| 88 | 
            +
                  create_table :party_relationships do |t|
         | 
| 89 | 
            +
                    t.column :description, :string
         | 
| 90 | 
            +
                    t.column :party_id_from, :integer
         | 
| 91 | 
            +
                    t.column :party_id_to, :integer
         | 
| 92 | 
            +
                    t.column :role_type_id_from, :integer
         | 
| 93 | 
            +
                    t.column :role_type_id_to, :integer
         | 
| 94 | 
            +
                    t.column :status_type_id, :integer
         | 
| 95 | 
            +
                    t.column :priority_type_id, :integer
         | 
| 96 | 
            +
                    t.column :relationship_type_id, :integer
         | 
| 97 | 
            +
                    t.column :from_date, :date
         | 
| 98 | 
            +
                    t.column :thru_date, :date
         | 
| 99 | 
            +
                    t.column :external_identifier, :string
         | 
| 100 | 
            +
                    t.column :external_id_source, :string
         | 
| 101 | 
            +
                    t.timestamps
         | 
| 102 | 
            +
                  end
         | 
| 103 | 
            +
                  add_index :party_relationships, :status_type_id
         | 
| 104 | 
            +
                  add_index :party_relationships, :priority_type_id
         | 
| 105 | 
            +
                  add_index :party_relationships, :relationship_type_id
         | 
| 106 | 
            +
                end
         | 
| 107 | 
            +
             | 
| 108 | 
            +
                # Create organizations table
         | 
| 109 | 
            +
                unless table_exists?(:organizations)
         | 
| 110 | 
            +
                  create_table :organizations do |t|
         | 
| 111 | 
            +
                    t.column :description, :string
         | 
| 112 | 
            +
                    t.column :tax_id_number, :string
         | 
| 113 | 
            +
                    t.timestamps
         | 
| 114 | 
            +
                  end
         | 
| 115 | 
            +
                end
         | 
| 116 | 
            +
             | 
| 117 | 
            +
                # Create individuals table 
         | 
| 118 | 
            +
                unless table_exists?(:individuals)
         | 
| 119 | 
            +
                  create_table :individuals do |t|
         | 
| 120 | 
            +
                    t.column :party_id, :integer
         | 
| 121 | 
            +
                    t.column :current_last_name, :string
         | 
| 122 | 
            +
                    t.column :current_first_name, :string
         | 
| 123 | 
            +
                    t.column :current_middle_name, :string
         | 
| 124 | 
            +
                    t.column :current_personal_title, :string
         | 
| 125 | 
            +
                    t.column :current_suffix, :string
         | 
| 126 | 
            +
                    t.column :current_nickname, :string
         | 
| 127 | 
            +
                    t.column :gender, :string, :limit => 1
         | 
| 128 | 
            +
                    t.column :birth_date, :date
         | 
| 129 | 
            +
                    t.column :height, :decimal, :precision => 5, :scale => 2
         | 
| 130 | 
            +
                    t.column :weight, :integer
         | 
| 131 | 
            +
                    t.column :mothers_maiden_name, :string
         | 
| 132 | 
            +
                    t.column :marital_status, :string, :limit => 1
         | 
| 133 | 
            +
                    t.column :social_security_number, :string
         | 
| 134 | 
            +
                    t.column :current_passport_number, :integer
         | 
| 135 | 
            +
             | 
| 136 | 
            +
                    t.column :current_passport_expire_date, :date
         | 
| 137 | 
            +
                    t.column :total_years_work_experience, :integer
         | 
| 138 | 
            +
                    t.column :comments, :string
         | 
| 139 | 
            +
                    t.column :encrypted_ssn, :string
         | 
| 140 | 
            +
                    t.column :temp_ssn, :string
         | 
| 141 | 
            +
                    t.column :salt, :string
         | 
| 142 | 
            +
                    t.column :ssn_last_four, :string
         | 
| 143 | 
            +
                    t.timestamps
         | 
| 144 | 
            +
                  end
         | 
| 145 | 
            +
                  add_index :individuals, :party_id
         | 
| 146 | 
            +
                end
         | 
| 147 | 
            +
             | 
| 148 | 
            +
                # Create contacts table
         | 
| 149 | 
            +
                unless table_exists?(:contacts)
         | 
| 150 | 
            +
                  create_table :contacts do |t|
         | 
| 151 | 
            +
                    t.column :party_id, :integer
         | 
| 152 | 
            +
                    t.column :contact_mechanism_id, :integer
         | 
| 153 | 
            +
                    t.column :contact_mechanism_type, :string
         | 
| 154 | 
            +
             | 
| 155 | 
            +
                    t.column :external_identifier, :string
         | 
| 156 | 
            +
                    t.column :external_id_source, :string
         | 
| 157 | 
            +
             | 
| 158 | 
            +
                    t.timestamps
         | 
| 159 | 
            +
                  end
         | 
| 160 | 
            +
                  add_index :contacts, :party_id
         | 
| 161 | 
            +
                  add_index :contacts, [:contact_mechanism_id, :contact_mechanism_type], :name => "besi_2"
         | 
| 162 | 
            +
                end
         | 
| 163 | 
            +
             | 
| 164 | 
            +
                # Create contact_types
         | 
| 165 | 
            +
                unless table_exists?(:contact_types)
         | 
| 166 | 
            +
                  create_table :contact_types do |t|
         | 
| 167 | 
            +
                    t.column :parent_id, :integer
         | 
| 168 | 
            +
                    t.column :lft, :integer
         | 
| 169 | 
            +
                    t.column :rgt, :integer
         | 
| 170 | 
            +
             | 
| 171 | 
            +
                    #custom columns go here   
         | 
| 172 | 
            +
             | 
| 173 | 
            +
                    t.column :description, :string
         | 
| 174 | 
            +
                    t.column :comments, :string
         | 
| 175 | 
            +
             | 
| 176 | 
            +
                    t.column :internal_identifier, :string
         | 
| 177 | 
            +
                    t.column :external_identifier, :string
         | 
| 178 | 
            +
                    t.column :external_id_source, :string
         | 
| 179 | 
            +
             | 
| 180 | 
            +
                    t.timestamps
         | 
| 181 | 
            +
                  end
         | 
| 182 | 
            +
                  add_index :contact_types, :parent_id
         | 
| 183 | 
            +
                end
         | 
| 184 | 
            +
             | 
| 185 | 
            +
                # Create contact_purposes
         | 
| 186 | 
            +
                unless table_exists?(:contact_purposes)
         | 
| 187 | 
            +
                  create_table :contact_purposes do |t|
         | 
| 188 | 
            +
             | 
| 189 | 
            +
                    t.column :parent_id, :integer
         | 
| 190 | 
            +
                    t.column :lft, :integer
         | 
| 191 | 
            +
                    t.column :rgt, :integer
         | 
| 192 | 
            +
             | 
| 193 | 
            +
                    #custom columns go here   
         | 
| 194 | 
            +
             | 
| 195 | 
            +
                    t.column :description, :string
         | 
| 196 | 
            +
                    t.column :comments, :string
         | 
| 197 | 
            +
             | 
| 198 | 
            +
                    t.column :internal_identifier, :string
         | 
| 199 | 
            +
                    t.column :external_identifier, :string
         | 
| 200 | 
            +
                    t.column :external_id_source, :string
         | 
| 201 | 
            +
             | 
| 202 | 
            +
                    t.timestamps
         | 
| 203 | 
            +
                  end
         | 
| 204 | 
            +
                  add_index :contact_purposes, :parent_id
         | 
| 205 | 
            +
             | 
| 206 | 
            +
                end
         | 
| 207 | 
            +
             | 
| 208 | 
            +
                unless table_exists?(:contact_purposes_contacts)
         | 
| 209 | 
            +
                  create_table :contact_purposes_contacts, {:id => false} do |t|
         | 
| 210 | 
            +
                    t.column :contact_id, :integer
         | 
| 211 | 
            +
                    t.column :contact_purpose_id, :integer
         | 
| 212 | 
            +
                  end
         | 
| 213 | 
            +
                  add_index :contact_purposes_contacts, [:contact_id, :contact_purpose_id], :name => "contact_purposes_contacts_index"
         | 
| 214 | 
            +
                end
         | 
| 215 | 
            +
             | 
| 216 | 
            +
                # Create postal_addresses (a contact_mechanism)
         | 
| 217 | 
            +
                unless table_exists?(:postal_addresses)
         | 
| 218 | 
            +
                  create_table :postal_addresses do |t|
         | 
| 219 | 
            +
                    t.column :address_line_1, :string
         | 
| 220 | 
            +
                    t.column :address_line_2, :string
         | 
| 221 | 
            +
                    t.column :city, :string
         | 
| 222 | 
            +
                    t.column :state, :string
         | 
| 223 | 
            +
                    t.column :zip, :string
         | 
| 224 | 
            +
                    t.column :country, :string
         | 
| 225 | 
            +
                    t.column :description, :string
         | 
| 226 | 
            +
                    t.column :geo_country_id, :integer
         | 
| 227 | 
            +
                    t.column :geo_zone_id, :integer
         | 
| 228 | 
            +
                    t.timestamps
         | 
| 229 | 
            +
                  end
         | 
| 230 | 
            +
                  add_index :postal_addresses, :geo_country_id
         | 
| 231 | 
            +
                  add_index :postal_addresses, :geo_zone_id
         | 
| 232 | 
            +
                end
         | 
| 233 | 
            +
             | 
| 234 | 
            +
                # Create email_addresses (a contact_mechanism)
         | 
| 235 | 
            +
                unless table_exists?(:email_addresses)
         | 
| 236 | 
            +
                  create_table :email_addresses do |t|
         | 
| 237 | 
            +
                    t.column :email_address, :string
         | 
| 238 | 
            +
                    t.column :description, :string
         | 
| 239 | 
            +
             | 
| 240 | 
            +
                    t.timestamps
         | 
| 241 | 
            +
                  end
         | 
| 242 | 
            +
                end
         | 
| 243 | 
            +
             | 
| 244 | 
            +
                # Create phone_numbers table (A contact_mechanism)
         | 
| 245 | 
            +
                unless table_exists?(:phone_numbers)
         | 
| 246 | 
            +
                  create_table :phone_numbers do |t|
         | 
| 247 | 
            +
                    t.column :phone_number, :string
         | 
| 248 | 
            +
                    t.column :description, :string
         | 
| 249 | 
            +
             | 
| 250 | 
            +
                    t.timestamps
         | 
| 251 | 
            +
                  end
         | 
| 252 | 
            +
                end
         | 
| 253 | 
            +
             | 
| 254 | 
            +
                unless table_exists?(:party_search_facts)
         | 
| 255 | 
            +
                  create_table :party_search_facts do |t|
         | 
| 256 | 
            +
                    t.column :party_id, :integer
         | 
| 257 | 
            +
                    t.column :eid, :string
         | 
| 258 | 
            +
                    t.column :type, :string
         | 
| 259 | 
            +
                    t.column :roles, :text
         | 
| 260 | 
            +
                    t.column :party_description, :string
         | 
| 261 | 
            +
                    t.column :party_business_party_type, :string
         | 
| 262 | 
            +
                    t.column :user_login, :string
         | 
| 263 | 
            +
                    t.column :individual_current_last_name, :string
         | 
| 264 | 
            +
                    t.column :individual_current_first_name, :string
         | 
| 265 | 
            +
                    t.column :individual_current_middle_name, :string
         | 
| 266 | 
            +
                    t.column :individual_birth_date, :string
         | 
| 267 | 
            +
                    t.column :individual_ssn, :string
         | 
| 268 | 
            +
                    t.column :party_phone_number, :string
         | 
| 269 | 
            +
                    t.column :party_email_address, :string
         | 
| 270 | 
            +
                    t.column :party_address_1, :string
         | 
| 271 | 
            +
                    t.column :party_address_2, :string
         | 
| 272 | 
            +
                    t.column :party_primary_address_city, :string
         | 
| 273 | 
            +
                    t.column :party_primary_address_state, :string
         | 
| 274 | 
            +
                    t.column :party_primary_address_zip, :string
         | 
| 275 | 
            +
                    t.column :party_primary_address_country, :string
         | 
| 276 | 
            +
                    t.column :user_enabled, :boolean
         | 
| 277 | 
            +
                    t.column :user_type, :string
         | 
| 278 | 
            +
                    t.column :reindex, :boolean
         | 
| 279 | 
            +
                    t.timestamps
         | 
| 280 | 
            +
                  end
         | 
| 281 | 
            +
                end
         | 
| 282 | 
            +
             | 
| 283 | 
            +
                unless table_exists?(:money)
         | 
| 284 | 
            +
                  create_table :money do |t|
         | 
| 285 | 
            +
                    t.string      :description
         | 
| 286 | 
            +
                    t.decimal     :amount, :precision => 8, :scale => 2
         | 
| 287 | 
            +
                    t.references  :currency 
         | 
| 288 | 
            +
                    t.timestamps
         | 
| 289 | 
            +
                  end
         | 
| 290 | 
            +
                  add_index :money, :currency_id
         | 
| 291 | 
            +
                end
         | 
| 292 | 
            +
             | 
| 293 | 
            +
                unless table_exists?(:currencies)
         | 
| 294 | 
            +
                  create_table :currencies do |t|
         | 
| 295 | 
            +
                    t.string :name
         | 
| 296 | 
            +
                    t.string :definition
         | 
| 297 | 
            +
                    t.string :internal_identifier # aka alphabetic_code
         | 
| 298 | 
            +
                    t.string :numeric_code
         | 
| 299 | 
            +
                    t.string :major_unit_symbol
         | 
| 300 | 
            +
                    t.string :minor_unit_symbol
         | 
| 301 | 
            +
                    t.string :ratio_of_minor_unit_to_major_unit
         | 
| 302 | 
            +
                    t.string :postfix_label
         | 
| 303 | 
            +
                    t.datetime :introduction_date
         | 
| 304 | 
            +
                    t.datetime :expiration_date
         | 
| 305 | 
            +
                    t.timestamps
         | 
| 306 | 
            +
                  end
         | 
| 307 | 
            +
                  add_index :currencies, :internal_identifier
         | 
| 308 | 
            +
                end
         | 
| 309 | 
            +
             | 
| 310 | 
            +
                ## categories
         | 
| 311 | 
            +
                unless table_exists?(:categories)
         | 
| 312 | 
            +
                  create_table :categories do |t|
         | 
| 313 | 
            +
                    t.string :description
         | 
| 314 | 
            +
                    t.string :external_identifier
         | 
| 315 | 
            +
                    t.datetime :from_date
         | 
| 316 | 
            +
                    t.datetime :to_date
         | 
| 317 | 
            +
                    t.string :internal_identifier
         | 
| 318 | 
            +
             | 
| 319 | 
            +
                    # polymorphic assns
         | 
| 320 | 
            +
                    t.integer :category_record_id
         | 
| 321 | 
            +
                    t.string :category_record_type
         | 
| 322 | 
            +
             | 
| 323 | 
            +
                    # nested set cols
         | 
| 324 | 
            +
                    t.integer :parent_id
         | 
| 325 | 
            +
                    t.integer :lft
         | 
| 326 | 
            +
                    t.integer :rgt
         | 
| 327 | 
            +
             | 
| 328 | 
            +
                    t.timestamps
         | 
| 329 | 
            +
                  end
         | 
| 330 | 
            +
                  add_index :categories, [:category_record_id, :category_record_type], :name => "category_polymorphic"
         | 
| 331 | 
            +
                end
         | 
| 332 | 
            +
             | 
| 333 | 
            +
                ## category_classifications
         | 
| 334 | 
            +
                unless table_exists?(:category_classifications)
         | 
| 335 | 
            +
                  create_table :category_classifications do |t|
         | 
| 336 | 
            +
                    t.integer :category_id
         | 
| 337 | 
            +
                    t.string :classification_type
         | 
| 338 | 
            +
                    t.integer :classification_id
         | 
| 339 | 
            +
                    t.datetime :from_date
         | 
| 340 | 
            +
                    t.datetime :to_date
         | 
| 341 | 
            +
             | 
| 342 | 
            +
                    t.timestamps
         | 
| 343 | 
            +
                  end
         | 
| 344 | 
            +
                  add_index :category_classifications, [:classification_id, :classification_type], :name => "classification_polymorphic"
         | 
| 345 | 
            +
                end
         | 
| 346 | 
            +
             | 
| 347 | 
            +
                ## descriptive_assets
         | 
| 348 | 
            +
                unless table_exists?(:descriptive_assets)
         | 
| 349 | 
            +
                  create_table :descriptive_assets do |t|
         | 
| 350 | 
            +
                    t.references :view_type
         | 
| 351 | 
            +
                    t.string :internal_identifier
         | 
| 352 | 
            +
                    t.text :description
         | 
| 353 | 
            +
                    t.string :external_identifier
         | 
| 354 | 
            +
                    t.string :external_id_source
         | 
| 355 | 
            +
                    t.references :described_record, :polymorphic => true
         | 
| 356 | 
            +
             | 
| 357 | 
            +
                    t.timestamps
         | 
| 358 | 
            +
                  end
         | 
| 359 | 
            +
             | 
| 360 | 
            +
                  add_index :descriptive_assets, :view_type_id
         | 
| 361 | 
            +
                  add_index :descriptive_assets, [:described_record_id, :described_record_type], :name => 'described_record_idx'
         | 
| 362 | 
            +
                end
         | 
| 363 | 
            +
             | 
| 364 | 
            +
                unless table_exists?(:view_types)
         | 
| 365 | 
            +
                  create_table :view_types do |t|
         | 
| 366 | 
            +
                    t.string :internal_identifier
         | 
| 367 | 
            +
                    t.string :description
         | 
| 368 | 
            +
             | 
| 369 | 
            +
                    t.timestamps
         | 
| 370 | 
            +
                  end
         | 
| 371 | 
            +
                end
         | 
| 372 | 
            +
             | 
| 373 | 
            +
                unless table_exists?(:geo_countries)
         | 
| 374 | 
            +
                  create_table :geo_countries do |t|
         | 
| 375 | 
            +
                    t.column :name, :string
         | 
| 376 | 
            +
                    t.column :iso_code_2, :string, :length => 2
         | 
| 377 | 
            +
                    t.column :iso_code_3, :string, :length => 3
         | 
| 378 | 
            +
                    t.column :display, :boolean, :default => true
         | 
| 379 | 
            +
                    t.column :external_id, :integer
         | 
| 380 | 
            +
                    t.column :created_at, :datetime
         | 
| 381 | 
            +
                  end
         | 
| 382 | 
            +
                  add_index :geo_countries, :name
         | 
| 383 | 
            +
                  add_index :geo_countries, :iso_code_2
         | 
| 384 | 
            +
                end
         | 
| 385 | 
            +
             | 
| 386 | 
            +
                unless table_exists?(:geo_zones)
         | 
| 387 | 
            +
                  create_table :geo_zones do |t|
         | 
| 388 | 
            +
                    t.column :geo_country_id, :integer
         | 
| 389 | 
            +
                    t.column :zone_code, :string, :default => 2
         | 
| 390 | 
            +
                    t.column :zone_name, :string
         | 
| 391 | 
            +
                    t.column :created_at, :datetime
         | 
| 392 | 
            +
                  end
         | 
| 393 | 
            +
                  add_index :geo_zones, :geo_country_id
         | 
| 394 | 
            +
                  add_index :geo_zones, :zone_name
         | 
| 395 | 
            +
                  add_index :geo_zones, :zone_code
         | 
| 396 | 
            +
                end
         | 
| 397 | 
            +
             | 
| 398 | 
            +
                unless table_exists?(:notes)
         | 
| 399 | 
            +
                  create_table :notes do |t|
         | 
| 400 | 
            +
                    t.integer :created_by_id
         | 
| 401 | 
            +
                    t.text :content
         | 
| 402 | 
            +
                    t.references :noted_record, :polymorphic => true
         | 
| 403 | 
            +
                    t.references :note_type
         | 
| 404 | 
            +
             | 
| 405 | 
            +
                    t.timestamps
         | 
| 406 | 
            +
                  end
         | 
| 407 | 
            +
             | 
| 408 | 
            +
                  add_index :notes, [:noted_record_id, :noted_record_type]
         | 
| 409 | 
            +
                  add_index :notes, :note_type_id
         | 
| 410 | 
            +
                  add_index :notes, :created_by_id
         | 
| 411 | 
            +
                end
         | 
| 412 | 
            +
             | 
| 413 | 
            +
                unless table_exists?(:note_types)
         | 
| 414 | 
            +
                  create_table :note_types do |t|
         | 
| 415 | 
            +
                    #these columns are required to support the behavior of the plugin 'awesome_nested_set'
         | 
| 416 | 
            +
                    t.integer :parent_id
         | 
| 417 | 
            +
                    t.integer :lft
         | 
| 418 | 
            +
                    t.integer :rgt
         | 
| 419 | 
            +
             | 
| 420 | 
            +
                    t.string :description
         | 
| 421 | 
            +
                    t.string :internal_identifier
         | 
| 422 | 
            +
                    t.string :external_identifier
         | 
| 423 | 
            +
                    t.references :note_type_record, :polymorphic => true
         | 
| 424 | 
            +
             | 
| 425 | 
            +
                    t.timestamps
         | 
| 426 | 
            +
                  end
         | 
| 427 | 
            +
             | 
| 428 | 
            +
                  add_index :note_types, [:note_type_record_id, :note_type_record_type], :name => "note_type_record_idx"
         | 
| 429 | 
            +
                end
         | 
| 430 | 
            +
             | 
| 431 | 
            +
                unless table_exists?(:valid_note_types)
         | 
| 432 | 
            +
                  create_table :valid_note_types do |t|
         | 
| 433 | 
            +
                    t.references :valid_note_type_record, :polymorphic => true
         | 
| 434 | 
            +
                    t.references :note_type
         | 
| 435 | 
            +
             | 
| 436 | 
            +
                    t.timestamps
         | 
| 437 | 
            +
                  end
         | 
| 438 | 
            +
             | 
| 439 | 
            +
                  add_index :valid_note_types, [:valid_note_type_record_id, :valid_note_type_record_type], :name => "valid_note_type_record_idx"
         | 
| 440 | 
            +
                  add_index :valid_note_types, :note_type_id
         | 
| 441 | 
            +
                end
         | 
| 442 | 
            +
             | 
| 443 | 
            +
              end
         | 
| 444 | 
            +
             | 
| 445 | 
            +
              def self.down
         | 
| 446 | 
            +
                [
         | 
| 447 | 
            +
                    :currencies, :money,
         | 
| 448 | 
            +
                    :party_search_facts, :phone_numbers, :email_addresses,
         | 
| 449 | 
            +
                    :postal_addresses, :contact_purposes, :contact_types,
         | 
| 450 | 
            +
                    :contacts, :individuals, :organizations,
         | 
| 451 | 
            +
                    :party_relationships, :relationship_types, :role_types,
         | 
| 452 | 
            +
                    :party_roles, :parties, :categories, :category_classifications,
         | 
| 453 | 
            +
                    :descriptive_assets, :view_types, :notes, :note_types, :valid_note_types, :compass_ae_instances
         | 
| 454 | 
            +
                ].each do |tbl|
         | 
| 455 | 
            +
                  if table_exists?(tbl)
         | 
| 456 | 
            +
                    drop_table tbl
         | 
| 457 | 
            +
                  end
         | 
| 458 | 
            +
                end
         | 
| 459 | 
            +
             | 
| 460 | 
            +
              end
         | 
| 461 | 
            +
            end
         |