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_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]}
|
||||||
before_destroy :xml_rpc_destroy
|
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_create lambda { symlink_directory unless hidden? }
|
||||||
after_destroy lambda { remove_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_order, order("CHAR_LENGTH(name) ASC")
|
||||||
scope :search, lambda {|q| where("name ILIKE ?", "%#{q.to_s.strip}%")}
|
scope :search, lambda {|q| where("name ILIKE ?", "%#{q.to_s.strip}%")}
|
||||||
scope :by_visibilities, lambda {|v| where(:visibility => v)}
|
scope :by_visibilities, lambda {|v| where(:visibility => v)}
|
||||||
|
@ -230,10 +229,11 @@ class Platform < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
later :xml_rpc_clone, :loner => true, :queue => :clone_build
|
later :xml_rpc_clone, :loner => true, :queue => :clone_build
|
||||||
|
|
||||||
def freeze_platform
|
def freeze_platform_and_update_repos
|
||||||
if released_changed? && released == true
|
if released_changed? && released == true
|
||||||
result = BuildServer.freeze(name)
|
result = BuildServer.freeze(name)
|
||||||
raise "Failed freeze platform #{name} with code #{result}" if result != BuildServer::SUCCESS
|
raise "Failed freeze platform #{name} with code #{result}" if result != BuildServer::SUCCESS
|
||||||
|
repositories.update_all(:publish_without_qa => false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
class AddPublishWithoutQaToRepositories < ActiveRecord::Migration
|
class AddPublishWithoutQaToRepositories < ActiveRecord::Migration
|
||||||
|
|
||||||
class Platform < ActiveRecord::Base
|
class Platform < ActiveRecord::Base
|
||||||
|
has_many :repositories, :dependent => :destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
class Repository < ActiveRecord::Base
|
class Repository < ActiveRecord::Base
|
||||||
|
@ -9,8 +10,8 @@ class AddPublishWithoutQaToRepositories < ActiveRecord::Migration
|
||||||
|
|
||||||
def up
|
def up
|
||||||
add_column :repositories, :publish_without_qa, :boolean, :default => true
|
add_column :repositories, :publish_without_qa, :boolean, :default => true
|
||||||
Repository.where('platforms.released is true').joins(:platform).
|
Platform.where(:released => true).each{|p| p.repositories.update_all(:publish_without_qa => false)}
|
||||||
update_all(:publish_without_qa => false)
|
Platform.where(:released => false).each{|p| p.repositories.update_all(:publish_without_qa => true)}
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
|
|
|
@ -413,9 +413,6 @@ ActiveRecord::Schema.define(:version => 20120906115648) do
|
||||||
t.string "role"
|
t.string "role"
|
||||||
t.string "language", :default => "en"
|
t.string "language", :default => "en"
|
||||||
t.integer "own_projects_count", :default => 0, :null => false
|
t.integer "own_projects_count", :default => 0, :null => false
|
||||||
t.string "confirmation_token"
|
|
||||||
t.datetime "confirmed_at"
|
|
||||||
t.datetime "confirmation_sent_at"
|
|
||||||
t.text "professional_experience"
|
t.text "professional_experience"
|
||||||
t.string "site"
|
t.string "site"
|
||||||
t.string "company"
|
t.string "company"
|
||||||
|
@ -427,6 +424,9 @@ ActiveRecord::Schema.define(:version => 20120906115648) do
|
||||||
t.integer "failed_attempts", :default => 0
|
t.integer "failed_attempts", :default => 0
|
||||||
t.string "unlock_token"
|
t.string "unlock_token"
|
||||||
t.datetime "locked_at"
|
t.datetime "locked_at"
|
||||||
|
t.string "confirmation_token"
|
||||||
|
t.datetime "confirmed_at"
|
||||||
|
t.datetime "confirmation_sent_at"
|
||||||
t.string "authentication_token"
|
t.string "authentication_token"
|
||||||
t.integer "build_priority", :default => 50
|
t.integer "build_priority", :default => 50
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue