Set publish_without_qa to false for all platform repos when released. Fix mgration. Refs #631
This commit is contained in:
parent
768e40ee2a
commit
7570f1cab7
|
@ -28,13 +28,12 @@ class Platform < ActiveRecord::Base
|
|||
before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]}
|
||||
before_destroy :xml_rpc_destroy
|
||||
|
||||
after_update :freeze_platform
|
||||
after_update :freeze_platform_and_update_repos
|
||||
after_update :update_owner_relation
|
||||
|
||||
after_create lambda { symlink_directory unless hidden? }
|
||||
after_destroy lambda { remove_symlink_directory unless hidden? }
|
||||
|
||||
after_update :update_owner_relation
|
||||
|
||||
scope :search_order, order("CHAR_LENGTH(name) ASC")
|
||||
scope :search, lambda {|q| where("name ILIKE ?", "%#{q.to_s.strip}%")}
|
||||
scope :by_visibilities, lambda {|v| where(:visibility => v)}
|
||||
|
@ -230,10 +229,11 @@ class Platform < ActiveRecord::Base
|
|||
end
|
||||
later :xml_rpc_clone, :loner => true, :queue => :clone_build
|
||||
|
||||
def freeze_platform
|
||||
def freeze_platform_and_update_repos
|
||||
if released_changed? && released == true
|
||||
result = BuildServer.freeze(name)
|
||||
raise "Failed freeze platform #{name} with code #{result}" if result != BuildServer::SUCCESS
|
||||
repositories.update_all(:publish_without_qa => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
class AddPublishWithoutQaToRepositories < ActiveRecord::Migration
|
||||
|
||||
class Platform < ActiveRecord::Base
|
||||
has_many :repositories, :dependent => :destroy
|
||||
end
|
||||
|
||||
class Repository < ActiveRecord::Base
|
||||
|
@ -9,8 +10,8 @@ class AddPublishWithoutQaToRepositories < ActiveRecord::Migration
|
|||
|
||||
def up
|
||||
add_column :repositories, :publish_without_qa, :boolean, :default => true
|
||||
Repository.where('platforms.released is true').joins(:platform).
|
||||
update_all(:publish_without_qa => false)
|
||||
Platform.where(:released => true).each{|p| p.repositories.update_all(:publish_without_qa => false)}
|
||||
Platform.where(:released => false).each{|p| p.repositories.update_all(:publish_without_qa => true)}
|
||||
end
|
||||
|
||||
def down
|
||||
|
|
10
db/schema.rb
10
db/schema.rb
|
@ -411,11 +411,8 @@ ActiveRecord::Schema.define(:version => 20120906115648) do
|
|||
t.text "ssh_key"
|
||||
t.string "uname"
|
||||
t.string "role"
|
||||
t.string "language", :default => "en"
|
||||
t.integer "own_projects_count", :default => 0, :null => false
|
||||
t.string "confirmation_token"
|
||||
t.datetime "confirmed_at"
|
||||
t.datetime "confirmation_sent_at"
|
||||
t.string "language", :default => "en"
|
||||
t.integer "own_projects_count", :default => 0, :null => false
|
||||
t.text "professional_experience"
|
||||
t.string "site"
|
||||
t.string "company"
|
||||
|
@ -427,6 +424,9 @@ ActiveRecord::Schema.define(:version => 20120906115648) do
|
|||
t.integer "failed_attempts", :default => 0
|
||||
t.string "unlock_token"
|
||||
t.datetime "locked_at"
|
||||
t.string "confirmation_token"
|
||||
t.datetime "confirmed_at"
|
||||
t.datetime "confirmation_sent_at"
|
||||
t.string "authentication_token"
|
||||
t.integer "build_priority", :default => 50
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue