dev_aliyun
cxt 6 years ago
parent be80081623
commit 5551a1ae3b

@ -1,14 +1,14 @@
class CreateShixunServiceConfigs < ActiveRecord::Migration
def change
# create_table :shixun_service_configs do |t|
# t.references :shixun
# t.integer :cpu_limit, :default => 1
# t.integer :memory_limit, :default => 1024
# t.integer :request_limit, :default => 10
# t.float :lower_cpu_limit, :default => 0.1
# t.integer :resource_limit, :default => 10000
# t.references :mirror_repository
# t.timestamps
# end
create_table :shixun_service_configs do |t|
t.references :shixun
t.integer :cpu_limit, :default => 1
t.integer :memory_limit, :default => 1024
t.integer :request_limit, :default => 10
t.float :lower_cpu_limit, :default => 0.1
t.integer :resource_limit, :default => 10000
t.references :mirror_repository
t.timestamps
end
end
end

@ -1,19 +1,19 @@
class AddLimitForShixuns < ActiveRecord::Migration
def up
# if !Challenge.first.has_attribute?(:exec_time)
# add_column :challenges, :exec_time, :integer, :default => 120
# end
# Shixun.find_each do |shixun|
# shixun.challenges.update_all(:exec_time => shixun.exec_time)
# shixun.mirror_repositories.each do |mirror|
# ShixunServiceConfig.create!(:shixun_id => shixun.id,
# :cpu_limit => mirror.cpu_limit,
# :memory_limit => mirror.memory_limit,
# :request_limit => mirror.memory_limit / 3,
# :mirror_repository_id => mirror.id)
# end
# end
#
if !Challenge.first.has_attribute?(:exec_time)
add_column :challenges, :exec_time, :integer, :default => 120
end
Shixun.find_each do |shixun|
shixun.challenges.update_all(:exec_time => shixun.exec_time)
shixun.mirror_repositories.each do |mirror|
ShixunServiceConfig.create!(:shixun_id => shixun.id,
:cpu_limit => mirror.cpu_limit,
:memory_limit => mirror.memory_limit,
:request_limit => mirror.memory_limit / 3,
:mirror_repository_id => mirror.id)
end
end
end

@ -1,13 +1,13 @@
class ModifyRequestLimitForShixunServiceConfig < ActiveRecord::Migration
def up
# ShixunServiceConfig.find_each do |config|
# # repertoire_id = 5 代表的是大数据的镜像
# if config.mirror_repository.repertoire_id != 5
# config.update_column(:request_limit, 10)
# else
# puts("####---#{config.mirror_repository.name}")
# end
# end
ShixunServiceConfig.find_each do |config|
# repertoire_id = 5 代表的是大数据的镜像
if config.mirror_repository.repertoire_id != 5
config.update_column(:request_limit, 10)
else
puts("####---#{config.mirror_repository.name}")
end
end
end
def down

@ -1,12 +1,12 @@
class CreateUserAgents < ActiveRecord::Migration
def change
# create_table :user_agents do |t|
# t.string :type
# t.string :key
# t.string :ip
#
# t.timestamps
# end
# add_index(:user_agents, :ip, :unique => true)
create_table :user_agents do |t|
t.string :type
t.string :key
t.string :ip
t.timestamps
end
add_index(:user_agents, :ip, :unique => true)
end
end

@ -1,6 +1,6 @@
class ModifyTypeForUserAgents < ActiveRecord::Migration
def up
# rename_column :user_agents, :type, :agent_type
rename_column :user_agents, :type, :agent_type
end
def down

Loading…
Cancel
Save