Skip to content

Commit

Permalink
Add internal column to ServiceTemplate table
Browse files Browse the repository at this point in the history
  • Loading branch information
hsong-rh committed Jul 19, 2018
1 parent 176add9 commit 74a8eda
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
17 changes: 17 additions & 0 deletions db/migrate/20180719163110_add_internal_to_service_template.rb
@@ -0,0 +1,17 @@
class AddInternalToServiceTemplate < ActiveRecord::Migration[5.0]
class ServiceTemplate < ActiveRecord::Base
self.inheritance_column = :_type_disabled
end

def up
add_column :service_templates, :internal, :boolean

say_with_time("Set ServiceTemplate internal") do
ServiceTemplate.where(:type => "ServiceTemplateTransformationPlan").update_all(:internal => true)
end
end

def down
remove_column :service_templates, :internal
end
end
@@ -0,0 +1,23 @@
require_migration

describe AddInternalToServiceTemplate do
let(:service_template_stub) { migration_stub(:ServiceTemplate) }

migration_context :up do
it "sets internal to true when type is ServiceTemplateTransformationPlan" do
st = service_template_stub.create!(:type => 'ServiceTemplateTransformationPlan')

migrate

expect(st.reload.internal).to be_truthy
end

it "skip internal for other types" do
st = service_template_stub.create!(:type => 'OtherServiceTemplateType')

migrate

expect(st.reload.internal).to be_nil
end
end
end

0 comments on commit 74a8eda

Please sign in to comment.