code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integrati... | Ruby |
module BaseObjects
def create_base_objects
@prog = FactoryGirl.create(:program, :title => 'Program')
@opt_reg = FactoryGirl.create(:option, :title => 'Regulation', :role => 'directive_kind')
@opt_com = FactoryGirl.create(:option, :title => 'Company Policy', :role => 'directive_kind')
@creg = FactoryGi... | Ruby |
FactoryGirl.define do
sequence(:slug) do |n|
# FIXME: Do I need to generate slugs according to a convention, or
# do they only need to be unique?
# FIXME: Slugs will become invalid if parenting is ever changed
# anywhere in the ancestor heirarchy.
# FIXME: Slug validation makes factories for secti... | Ruby |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :control_assessment do
pbc_list { |c| c.association(:pbc_list) }
control { |c| c.association(:control) }
control_version "MyString"
internal_tod false
internal_toe false
external_tod false
e... | Ruby |
# Test some of the authorization basics for resource controllers.
#
# Usage:
#
# require 'authorized_controller'
#
# before :each do
# @model = <model> # The model that you're testing authorization for, e.g. Account
# @object = <obj> # An instance you want to test read and update actions against
# @index_objs = ... | Ruby |
require 'spork'
require 'simplecov'
require 'capybara/rspec'
if ENV['COVERAGE']
SimpleCov.start do
add_group 'Models', 'app/models'
add_group 'Helpers', 'app/helpers'
add_group 'Controllers', 'app/controllers'
add_group 'Admin C', 'app/controllers/admin'
add_filter 'config'
add_fil... | Ruby |
module UserSpecHelper
# Set the rspec environment so that we can call stub_model
def set_rspec(rspec)
@_rspec = rspec
end
def current_user(stubs = {})
return @current_user if @current_user
role = (stubs.delete(:role) || :user).to_s
if respond_to?(:stub_model)
@current_user = stub_model(... | Ruby |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
ActiveRecord::Base.transaction do
# Categories
# Control categories
control_categories = [
["Access Contr... | Ruby |
SIZE=20
ACCOUNTS = {
:root => :superuser,
:user => :user,
:owner1 => :user,
:owner2 => :user
}
ActiveRecord::Base.transaction do
# Accounts
ACCOUNTS.each do |name, role|
Account.
where(:email => "#{name}@t.com").
first_or_create!(
{:password => name, :password_confirmation => name... | Ruby |
class MoveImportHelpPaths < ActiveRecord::Migration
def up
help = Help.where(:slug => 'import').first
help.update_attribute(:slug, 'systems_import') if help
help = Help.where(:slug => 'import_controls').first
help.update_attribute(:slug, 'controls_import') if help
end
def down
end
end
| Ruby |
class AddKindToDirectives < ActiveRecord::Migration
def change
add_column :directives, :kind, :string
end
end
| Ruby |
class CreateMeetings < ActiveRecord::Migration
def change
create_table :meetings do |t|
t.references :response
t.datetime :start_at
t.string :calendar_url
t.references :modified_by
t.timestamps
end
end
end
| Ruby |
class AddControlColumns < ActiveRecord::Migration
def up
change_table :controls do |t|
t.string :version
t.datetime :start_date
t.datetime :stop_date
t.string :url
t.text :documentation_description
t.references :verify_frequency
t.remove :frequency
t.remove :frequen... | Ruby |
class CreateLocations < ActiveRecord::Migration
def change
create_table :locations do |t|
t.string :slug
t.string :title
t.text :description
t.string :url
t.references :modified_by
t.datetime :start_date
t.datetime :stop_date
t.timestamps
end
end
end
| Ruby |
class FixRiskyAttributeRelationships < ActiveRecord::Migration
RELATIONSHIP_TYPE_NAME_CHANGES = [
[ :risky_attribute_is_an_attribute_of_org_group, :org_group_has_risky_attribute ],
[ :risky_attribute_is_an_attribute_of_product, :product_has_risky_attribute ],
[ :risky_attribute_is_an_attribute_of_loca... | Ruby |
class CreateObjectDocuments < ActiveRecord::Migration
class BizProcessDocument < ActiveRecord::Base
end
class DocumentSystem < ActiveRecord::Base
end
class DocumentSystemControl < ActiveRecord::Base
end
def change
create_table :object_documents do |t|
t.string :role
t.text :notes
t.... | Ruby |
class UpdateLanguagesAndControlKinds < ActiveRecord::Migration
def up
o = Option.where(:role => 'control_kind', :title => 'Directive').first
if o
o.title = 'Administrative'
o.save
end
o = Option.where(:role => 'control_means', :title => 'Manual with Segregation of Duties').first
if o
... | Ruby |
class RemoveControlIdFromRequests < ActiveRecord::Migration
def up
# replace all controls with adequate control assessments
Request.all.each do |request|
if request.control_id.present?
control_assessment = ControlAssessment.where(:control_id => request.control_id, :pbc_list_id => request.pbc_lis... | Ruby |
class MovePbcListsColumnsToCycles < ActiveRecord::Migration
def up
change_table :cycles do |t|
t.string :title
t.string :audit_firm
t.string :audit_lead
t.text :description
t.string :status
t.text :notes
end
Cycle.reset_column_information
Cycle.all.each do |cycle|... | Ruby |
class UniqueSlug < ActiveRecord::Migration
def up
add_index :sections, :slug, :unique => true
add_index :controls, :slug, :unique => true
add_index :biz_processes, :slug, :unique => true
add_index :systems, :slug, :unique => true
add_index :programs, :slug, :unique => true
end
def down
re... | Ruby |
class AddToProgram < ActiveRecord::Migration
def up
change_table :programs do |t|
t.integer :frequency_type, :default => 1
t.integer :frequency, :default => 1
end
end
def down
change_table :programs do |t|
t.remove :frequency, :frequency_type
end
end
end
| Ruby |
class SetProgramIdOnCycles < ActiveRecord::Migration
def up
transaction do
Cycle.all.each do |cycle|
directive = Directive.find(cycle.directive_id)
program = directive.programs.first
cycle.update_attribute(:program_id, program.id)
end
end
end
def down
end
end
| Ruby |
class CreateOptions < ActiveRecord::Migration
def change
create_table :options do |t|
t.string :role, :null => false
t.string :title, :null => false
t.text :description
t.references :modified_by
t.timestamps
end
end
end
| Ruby |
class AddNaToSection < ActiveRecord::Migration
def change
add_column :sections, :na, :boolean, :null => false, :default => false
add_column :sections, :notes, :text
end
end
| Ruby |
class CreateMarkets < ActiveRecord::Migration
def change
create_table :markets do |t|
t.string :slug
t.string :title
t.text :description
t.string :url
t.references :modified_by
t.datetime :start_date
t.datetime :stop_date
t.timestamps
end
end
end
| Ruby |
class ChangeRelationshipsFromLocationToFacility < ActiveRecord::Migration
def up
Relationship.where(:source_type => 'Location').all.each do |rel|
rel.update_attribute(:source_type, 'Facility')
end
Relationship.where(:destination_type => 'Location').all.each do |rel|
rel.update_attribute(:desti... | Ruby |
class ChangePolymorphicTypesToProgramFromDirective < ActiveRecord::Migration
RELATIONSHIP_TYPE_NAME_CHANGES = [
[:directive_applies_to_data_asset, :program_applies_to_data_asset],
[:directive_applies_to_facility, :program_applies_to_facility],
[:directive_applies_to_market, :program_applies_to_marke... | Ruby |
class AddBaseProgramKinds < ActiveRecord::Migration
def up
Option.where(:role => 'program_type').destroy_all
role = 'program_kind'
Option.where(:role => role, :title => 'Not Applicable').destroy_all
[
'Regulation', 'Company Policy', 'Operational Group Policy', 'Data Asset Policy'
].each d... | Ruby |
class AddUrlToSections < ActiveRecord::Migration
def change
add_column :sections, :url, :string
end
end
| Ruby |
class RemoveDeprecatedDatabaseObjects < ActiveRecord::Migration
def up
# BizProcess is now a subset/type of System
# - data migration happened in 20120723223448_copy_biz_processes_to_systems.rb
drop_table :biz_process_controls
drop_table :biz_process_documents
drop_table :biz_process_people
dr... | Ruby |
class CreateProjects < ActiveRecord::Migration
def change
create_table :projects do |t|
t.string :slug
t.string :title
t.text :description
t.string :url
t.references :modified_by
t.datetime :start_date
t.datetime :stop_date
t.timestamps
end
end
end
| Ruby |
class UpdateBaseRelationshipTypes < ActiveRecord::Migration
def up
RelationshipType.reset_column_information
new_relationship_types = [
# Relationship types are in alphabetical order!
{
:relationship_type => 'location_is_dependent_on_location',
:description => "Locations can be de... | Ruby |
class RemoveInvalidRiskyAttributes < ActiveRecord::Migration
def up
RiskyAttribute.where(:type_string => nil).each do |ra|
ra.destroy
end
RiskyAttribute.where(:type_string => "").each do |ra|
ra.destroy
end
RiskyAttribute.where(:type_string => "Org Group").each do |ra|
ra.updat... | Ruby |
class CreateObjectPeople < ActiveRecord::Migration
class BizProcessPerson < ActiveRecord::Base
end
class SystemPerson < ActiveRecord::Base
end
def change
create_table :object_people do |t|
t.string :role
t.text :notes
t.references :person, :null => false
t.references :personable, ... | Ruby |
class AddPopulationSampleFieldsToResponses < ActiveRecord::Migration
def change
add_column :responses, :population_document_id, :integer
add_column :responses, :population, :integer
add_column :responses, :sample_worksheet_document_id, :integer
add_column :responses, :samples, :integer
add_column ... | Ruby |
class FixCategories < ActiveRecord::Migration
def change
change_table :categorizations do |t|
t.belongs_to :modified_by
end
rename_column :categorizations, :stuff_id, :categorizable_id
rename_column :categorizations, :stuff_type, :categorizable_type
change_table :categories do |t|
t.b... | Ruby |
class ChangeCompanyControlsToPolicy < ActiveRecord::Migration
def up
transaction do
Directive.where(:kind => "Company Controls").each do |directive|
directive.kind = "Company Controls Policy"
directive.save!
end
end
end
def down
end
end
| Ruby |
class CreateRisks < ActiveRecord::Migration
def change
create_table :risks do |t|
t.string :slug
t.string :title
t.text :description
t.string :url
t.references :modified_by
t.datetime :start_date
t.datetime :stop_date
t.timestamps
end
end
end
| Ruby |
class AddDefaultOptionsAndCategories < ActiveRecord::Migration
def up
Option.reset_column_information
Category.reset_column_information
Categorization.reset_column_information
options = {
:control_type => [],
:control_kind => ["Reactive", "Directive", "Detective", "Preventative"],
:... | Ruby |
class AddProductStartStopDates < ActiveRecord::Migration
def up
change_table :products do |t|
t.datetime :start_date
t.datetime :stop_date
end
end
def down
change_table :products do |t|
t.remove :start_date
t.remove :stop_date
end
end
end
| Ruby |
class AddRequiredToCategories < ActiveRecord::Migration
def change
add_column :categories, :required, :boolean
end
end
| Ruby |
class ConsolidateRiskFields < ActiveRecord::Migration
def up
transaction do
Risk.all.each do |risk|
impact = [risk.financial_impact, risk.reputational_impact, risk.operational_impact]
impact = impact.map(&:presence).compact.join("<br />")
risk.update_attribute(:impact, impact)
... | Ruby |
class CreateRequests < ActiveRecord::Migration
def change
create_table :requests do |t|
t.references :pbc_list
t.references :type
t.references :control
t.string :pbc_control_code
t.text :pbc_control_desc
t.text :request
t.text :test
t.text :notes
t.string :com... | Ruby |
class RemoveParentheticalsFromStatusValues < ActiveRecord::Migration
REQUEST_STATUS_MIGRATIONS = [
["Responded (by Compliance)", "Responded"],
["Amended/Updated Request (by Auditor)", "Amended/Updated Request"],
["Accepted (by Auditor)", "Accepted"]
]
def up
REQUEST_STATUS_MIGRATIONS.each do |old... | Ruby |
class AddPersonLanguage < ActiveRecord::Migration
# Add a 'language_id' association from Person to the Option table
# Local models so that migration is safe
class Option < ActiveRecord::Base
attr_accessible :role, :title
end
def up
add_column :people, :language_id, :integer
Option.reset_column_... | Ruby |
class AddRequiredToOptions < ActiveRecord::Migration
def change
add_column :options, :required, :boolean
end
end
| Ruby |
class AddBaseMarketRelationships < ActiveRecord::Migration
def up
new_relationship_types = [
# Relationship types are in alphabetical order!
{
:relationship_type => 'market_contains_a_market',
:description => "Markets can have submarkets.",
:forward_phrase =>"containing",
... | Ruby |
class AddObjectObjectStartStopDates < ActiveRecord::Migration
def up
change_table :object_people do |t|
t.datetime :start_date
t.datetime :stop_date
end
change_table :object_documents do |t|
t.datetime :start_date
t.datetime :stop_date
end
end
def down
change_table :ob... | Ruby |
class AddProgramIdToCycles < ActiveRecord::Migration
def change
add_column :cycles, :program_id, :integer
end
end
| Ruby |
class AddNotesToSystems < ActiveRecord::Migration
def change
add_column :systems, :notes, :text
end
end
| Ruby |
class AddNotesToControls < ActiveRecord::Migration
def change
add_column :controls, :notes, :text
end
end
| Ruby |
class RenameLocationsToFacilities < ActiveRecord::Migration
RELATIONSHIP_TYPE_NAME_CHANGES = [
["location_has_process", "facility_has_process"],
["location_has_risky_attribute", "facility_has_risky_attribute"],
["location_is_dependent_on_location", "facility_is_dependent_on_faci... | Ruby |
class CreatePbcLists < ActiveRecord::Migration
def change
create_table :pbc_lists do |t|
t.references :audit_cycle
t.string :title
t.string :audit_firm
t.string :audit_lead
t.text :description
t.datetime :list_import_date
t.string :status
t.text :notes
t.refer... | Ruby |
class CreateHelps < ActiveRecord::Migration
def change
create_table :helps do |t|
t.string :slug
t.string :content
t.timestamps
end
end
end
| Ruby |
class CreateControlAssessments < ActiveRecord::Migration
def change
create_table :control_assessments do |t|
t.references :pbc_list
t.references :control
t.string :control_version
t.boolean :internal_tod, :default => nil, :null => true
t.boolean :internal_toe, :default => nil, :null ... | Ruby |
class AddOptionReferences < ActiveRecord::Migration
def up
change_table :controls do |t|
t.references :type
t.references :kind
t.references :means
end
change_table :systems do |t|
t.references :type
end
end
def down
change_table :controls do |t|
t.remove :type_i... | Ruby |
class AddPopulationSampleForExistingResponses < ActiveRecord::Migration
def up
Request.all.
select { |r| r.type_name == 'Population Sample' }.
map { |r| r.responses.all }.
flatten.
each { |r| r.create_population_sample if r.population_sample.nil? }
end
def down
end
end
| Ruby |
class RemoveNameFromAccounts < ActiveRecord::Migration
def up
Account.all.each do |a|
person = Person.find_by_email(a.email)
if person
person.name = "#{a.name} #{a.surname}"
person.save!(:validate => false)
else
a.person =
Person.create({:email => a.email,
... | Ruby |
class AddSystemsIsBizProcess < ActiveRecord::Migration
def up
change_table :systems do |t|
t.boolean :is_biz_process, :default => false
end
end
def down
change_table :systems do |t|
t.remove :is_biz_process
end
end
end
| Ruby |
class ChangeHelpsContentType < ActiveRecord::Migration
def up
change_column :helps, :content, :text, :limit => nil
end
def down
change_column :helps, :content, :string
end
end
| Ruby |
class SetDefaultKindForPrograms < ActiveRecord::Migration
def up
transaction do
Program.all.each do |program|
program.kind = "Directive" if program.kind.blank?
program.save!
end
end
end
def down
end
end
| Ruby |
class CreateBaseRelationshipTypes < ActiveRecord::Migration
class RelationshipType < ActiveRecord::Base
self.primary_key = 'relationship_type'
end
def up
RelationshipType.create({:relationship_type => 'within_scope_of',
:description => 'The source is within the scope of the ... | Ruby |
class AddKindToPrograms < ActiveRecord::Migration
def change
add_column :programs, :kind, :string
end
end
| Ruby |
class AddControlAssessmentIdToRequests < ActiveRecord::Migration
def change
add_column :requests, :control_assessment_id, :integer
add_index :requests, :control_assessment_id
end
end
| Ruby |
class UpdateRelationshipTypeIds < ActiveRecord::Migration
RELATIONSHIP_TYPE_NAME_CHANGES = [
[:program_is_relevant_to_org_group, :program_applies_to_org_group],
[:program_is_relevant_to_product, :program_applies_to_product],
[:program_is_relevant_to_facility, :program_applies_to_facility],
... | Ruby |
class AddProgramColumns < ActiveRecord::Migration
def up
change_table :programs do |t|
t.string :version
t.datetime :start_date
t.datetime :stop_date
t.string :url
t.string :organization
t.text :scope
t.references :kind
t.datetime :audit_start_date
t.reference... | Ruby |
class CreateResponses < ActiveRecord::Migration
def change
create_table :responses do |t|
t.references :request
t.references :system
t.string :status
t.references :modified_by
t.timestamps
end
end
end
| Ruby |
class ReorgControls < ActiveRecord::Migration
class Program < ActiveRecord::Base
end
class Section < ActiveRecord::Base
belongs_to :parent, :class_name => "Section"
end
def up
raise "do not know how to migrate ControlControls" unless ControlControl.count == 0
rename_table :control_control_object... | Ruby |
class RemovePbcListsColumns < ActiveRecord::Migration
def up
change_table :pbc_lists do |t|
t.remove :title
t.remove :description
t.remove :audit_firm
t.remove :audit_lead
t.remove :notes
t.remove :list_import_date
t.remove :status
end
end
def down
end
end
| Ruby |
class CreateProgramDirectives < ActiveRecord::Migration
def change
create_table :program_directives do |t|
t.references :program, :null => false
t.references :directive, :null => false
t.references :modified_by
t.timestamps
end
end
end
| Ruby |
class AddTypeToRiskyAttributes < ActiveRecord::Migration
def change
change_table :risky_attributes do |t|
t.string :type_string
end
end
end
| Ruby |
class FixResponsesWithoutPopSamples < ActiveRecord::Migration
def up
end
def down
end
end
| Ruby |
class CreateVersions < ActiveRecord::Migration
def self.up
create_table :versions do |t|
t.string :item_type, :null => false
t.integer :item_id, :null => false
t.string :event, :null => false
t.string :whodunnit
t.text :object
t.datetime :created_at
end
... | Ruby |
class AddPersonCompany < ActiveRecord::Migration
def up
add_column :people, :company, :string
end
def down
remove_column :people, :company
end
end
| Ruby |
class ChangeLikelihoodPg < ActiveRecord::Migration
def _is_postgresql?
begin
ActiveRecord::Base.connection.kind_of?(
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
rescue
false
end
end
def up
if _is_postgresql?
connection.execute(%q{
alter table risks... | Ruby |
class AddMissingSystemFields < ActiveRecord::Migration
def up
change_table :systems do |t|
t.datetime :start_date
t.datetime :stop_date
t.string :url
t.string :version
end
end
def down
change_table :systems do |t|
t.remove :start_date
t.remove :stop_date
t.re... | Ruby |
class AddAssertionsToControls < ActiveRecord::Migration
def change
change_table :controls do |t|
t.boolean :fraud_related
t.boolean :key_control
t.boolean :active
end
end
end
| Ruby |
class CreateTransactions < ActiveRecord::Migration
def change
create_table :transactions do |t|
t.string :title, :null => false
t.text :description
t.references :system
t.references :modified_by
t.timestamps
end
end
end
| Ruby |
class ChangeStatusValues < ActiveRecord::Migration
# "Draft" remains "Draft" in the new arrangement.
REQUEST_STATUS_MIGRATIONS = [
["Waiting Compliance", "Requested"],
["Waiting Auditors", "Responded (by Compliance)"],
["Completed", "Accepted (by Auditor)"]
]
def up
REQUEST_STATUS_M... | Ruby |
class FixResponsesWithoutPopSamples2 < ActiveRecord::Migration
def up
transaction do
Response
.joins( :request )
.where( :requests => { :type_id => 2 } )
.joins("left outer join population_samples as population_sample on population_sample.response_id = responses.id")
.where(:popu... | Ruby |
class AddCompanyControlsProgram < ActiveRecord::Migration
def up
transaction do
p = Program.where(:kind => "Company Controls").first
if p.nil?
p = Program.create(:kind => "Company Controls", :title => "Company Controls")
end
Directive.where(:kind => "Company Controls").each do |d|... | Ruby |
class ChangeDirectiveKindToString < ActiveRecord::Migration
def up
transaction do
Directive.all.each do |directive|
option = Option.where(:role => 'directive_kind', :id => directive.kind_id).first
kind = option ? option.title : "Regulation"
kind = "Org Group Policy" if kind == "Opera... | Ruby |
class AddRiskFields < ActiveRecord::Migration
def change
add_column :risks, :inherent_risk, :text
add_column :risks, :risk_mitigation, :text
add_column :risks, :residual_risk, :text
add_column :risks, :impact, :text
end
end
| Ruby |
class CreateDataAssets < ActiveRecord::Migration
def change
create_table :data_assets do |t|
t.string :slug
t.string :title
t.text :description
t.string :url
t.references :modified_by
t.datetime :start_date
t.datetime :stop_date
t.timestamps
end
end
end
| Ruby |
class RemoveDirectiveIdFromCycles < ActiveRecord::Migration
def up
remove_column :cycles, :directive_id
end
def down
add_column :cycles, :directive_id, :integer
end
end
| Ruby |
class FixRelationshipDescription < ActiveRecord::Migration
def up
rename_column :relationship_types, :forward_short_description, :forward_phrase
rename_column :relationship_types, :backward_short_description, :backward_phrase
end
def down
rename_column :relationship_types, :forward_phrase, :forward_s... | Ruby |
class CreateInitialTables < ActiveRecord::Migration
def up
create_table :accounts do |t|
t.string :username
t.string :name
t.string :surname
t.string :email
t.string :crypted_password
t.string :role
t.string :persistence_token
t.belongs_to :modified_by
t.time... | Ruby |
class FixCategoryScopes < ActiveRecord::Migration
def up
# Fix previously-created categories which don't specify a scope_id
Category.where(:scope_id => nil).update_all(:scope_id => Control::CATEGORY_TYPE_ID)
end
def down
end
end
| Ruby |
class AddTitleToHelps < ActiveRecord::Migration
def change
add_column :helps, :title, :string
end
end
| Ruby |
class AddProgramForEachDirective < ActiveRecord::Migration
def up
transaction do
Directive.all.each do |directive|
if directive.programs.count == 0
program = Program.create!(
:title => directive.title
)
program_directive = ProgramDirective.create!(
... | Ruby |
class RenameProgramsToDirectives < ActiveRecord::Migration
def up
rename_table :programs, :directives
rename_column :controls, :program_id, :directive_id
rename_column :sections, :program_id, :directive_id
rename_column :cycles, :program_id, :directive_id
end
def down
rename_table :directive... | Ruby |
class DeprecateUnusedAccountRoles < ActiveRecord::Migration
class Account < ActiveRecord::Base
end
def up
Account.where(:role => :admin).each do |account|
account.role = :superuser
account.save
end
Account.where(:role => :admin).each do |account|
account.role = :superuser
acc... | Ruby |
class CopyBizProcessesToSystems < ActiveRecord::Migration
class BizProcess < ActiveRecord::Base
end
def up
System.reset_column_information
# Copy BizProcess and relations to System
BizProcess.all.each do |bp|
sys = System.create!(
:title => bp.title,
:slug => bp.slug,
:... | Ruby |
class CreateCategories < ActiveRecord::Migration
def change
create_table :categories do |t|
t.string :name
t.integer :parent_id
t.integer :lft
t.integer :rgt
t.integer :scope_id
t.integer :depth
t.timestamps
end
create_table :categorizations do |t|
t.refer... | Ruby |
class AddNewRisksFields < ActiveRecord::Migration
def change
change_table :risks do |t|
t.text :likelihood
t.text :threat_vector
t.text :trigger
t.text :preconditions
t.text :financial_impact
t.text :reputational_impact
t.text :operational_impact
t.integer :likeli... | Ruby |
class FixNilRequestStatuses < ActiveRecord::Migration
def up
Request.where(:status => nil).all.each do |req|
req.update_attribute(:status, 'Draft')
end
end
def down
end
end
| Ruby |
class AddEndAtToCycles < ActiveRecord::Migration
def change
add_column :cycles, :end_at, :date
end
end
| Ruby |
class LinkAccountsAndPeople < ActiveRecord::Migration
# This migration does a few different things:
# Adds an association between accounts and people
# Renames the username attribute to email in people
# Links accounts to people via e-mail, creating people
# as necessary to map to accounts.
# Local models ... | Ruby |
class CreateOrgGroups < ActiveRecord::Migration
def change
create_table :org_groups do |t|
t.string :slug
t.string :title
t.text :description
t.string :url
t.references :modified_by
t.datetime :start_date
t.datetime :stop_date
t.timestamps
end
end
end
| Ruby |
class AddReportDueAtToAuditCycle < ActiveRecord::Migration
def change
add_column :cycles, :report_due_at, :date
end
end
| Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.