Merged several migrations.

This commit is contained in:
Martin Edenhofer 2014-12-17 21:39:28 +01:00
parent 761cd4253a
commit 37f421a4e5
10 changed files with 35 additions and 178 deletions

View file

@ -20,11 +20,19 @@ class CreateStorage < ActiveRecord::Migration
add_index :store_objects, [:name], :unique => true
create_table :store_files do |t|
t.column :data, :binary, :limit => 200.megabytes, :null => true
t.column :md5, :string, :limit => 60, :null => false
t.column :sha, :string, :limit => 128, :null => false
t.column :provider, :string, :limit => 20, :null => true
t.timestamps
end
add_index :store_files, [:md5], :unique => true
add_index :store_files, [:sha], :unique => true
add_index :store_files, [:provider]
create_table :store_provider_dbs do |t|
t.column :sha, :string, :limit => 128, :null => false
t.column :data, :binary, :limit => 200.megabytes, :null => true
t.timestamps
end
add_index :store_provider_dbs, [:sha], :unique => true
end

View file

@ -8,6 +8,7 @@ class SchedulerCreate < ActiveRecord::Migration
t.column :period, :integer, :null => true
t.column :running, :integer, :null => false, :default => false
t.column :last_run, :timestamp, :null => true
t.column :prio, :integer, :null => false
t.column :pid, :string, :limit => 250, :null => true
t.column :note, :string, :limit => 250, :null => true
t.column :active, :boolean, :null => false, :default => false
@ -16,26 +17,38 @@ class SchedulerCreate < ActiveRecord::Migration
t.timestamps
end
add_index :schedulers, [:name], :unique => true
Scheduler.create(
Scheduler.create_or_update(
:name => 'Import OTRS diff load',
:method => 'Import::OTRS2.diff_worker',
:period => 60 * 3,
:prio => 1,
:active => true,
:updated_by_id => 1,
:created_by_id => 1,
)
Scheduler.create_or_update(
:name => 'Check Channels',
:method => 'Channel.fetch',
:period => 30,
:prio => 1,
:active => true,
:updated_by_id => 1,
:created_by_id => 1,
)
Scheduler.create(
:name => 'Import OTRS diff load',
:method => 'Import::OTRS.diff_loop',
:period => 60 * 10,
:active => true,
:updated_by_id => 1,
:created_by_id => 1,
)
Scheduler.create(
Scheduler.create_or_update(
:name => 'Generate Session data',
:method => 'Session.jobs',
:method => 'Sessions.jobs',
:period => 60,
:prio => 1,
:active => true,
:updated_by_id => 1,
:created_by_id => 1,
)
Scheduler.create_or_update(
:name => 'Cleanup expired sessions',
:method => 'SessionHelper.cleanup_expired',
:period => 60 * 60 * 24,
:prio => 2,
:active => true,
:updated_by_id => 1,
:created_by_id => 1,

View file

@ -1,39 +0,0 @@
require 'scheduler'
require 'setting'
class SchedulerUpdate < ActiveRecord::Migration
def up
add_column :schedulers, :prio, :integer, :null => true
Scheduler.reset_column_information
Scheduler.create_or_update(
:name => 'Import OTRS diff load',
:method => 'Import::OTRS2.diff_worker',
:period => 60 * 3,
:prio => 1,
:active => true,
:updated_by_id => 1,
:created_by_id => 1,
)
Scheduler.create_or_update(
:name => 'Check Channels',
:method => 'Channel.fetch',
:period => 30,
:prio => 1,
:active => true,
:updated_by_id => 1,
:created_by_id => 1,
)
Scheduler.create_or_update(
:name => 'Generate Session data',
:method => 'Sessions.jobs',
:period => 60,
:prio => 1,
:active => true,
:updated_by_id => 1,
:created_by_id => 1,
)
end
def down
remove_column :schedulers, :prio
end
end

View file

@ -1,29 +0,0 @@
class UpdateGeo < ActiveRecord::Migration
def up
Setting.create_if_not_exists(
:title => 'Geo Location Backend',
:name => 'geo_backend',
:area => 'System::Geo',
:description => 'Defines the backend for geo location lookups.',
:options => {
:form => [
{
:display => '',
:null => true,
:name => 'geo_backend',
:tag => 'select',
:options => {
'' => '-',
'Gmaps' => 'Google Maps',
},
},
],
},
:state => 'Gmaps',
:frontend => true
)
end
def down
end
end

View file

@ -1,6 +1,5 @@
class UpdateGeo2 < ActiveRecord::Migration
def up
Setting.where( :name => 'geo_backend' ).destroy_all
Setting.create_if_not_exists(
:title => 'Geo Location Backend',
:name => 'geo_location_backend',

View file

@ -1,15 +0,0 @@
class UpdateScheduler2 < ActiveRecord::Migration
def up
Scheduler.create_or_update(
:name => 'Generate Session data',
:method => 'Sessions.jobs',
:period => 60,
:prio => 1,
:active => true,
:updated_by_id => 1,
:created_by_id => 1,
)
end
def down
end
end

View file

@ -1,15 +0,0 @@
class UpdateScheduler3 < ActiveRecord::Migration
def up
Scheduler.create_or_update(
:name => 'Cleanup expired sessions',
:method => 'SessionHelper.cleanup_expired',
:period => 60 * 60 * 24,
:prio => 2,
:active => true,
:updated_by_id => 1,
:created_by_id => 1,
)
end
def down
end
end

View file

@ -1,9 +0,0 @@
class UpdateStorage < ActiveRecord::Migration
def up
change_column :store_files, :data, :binary, :limit => 200.megabytes, :null => true
add_column :store_files, :file_system, :boolean, :null => false, :default => false
end
def down
end
end

View file

@ -1,28 +0,0 @@
class UpdateStorage2 < ActiveRecord::Migration
def up
create_table :store_provider_dbs do |t|
t.column :data, :binary, :limit => 200.megabytes, :null => true
t.column :md5, :string, :limit => 60, :null => false
t.timestamps
end
add_index :store_provider_dbs, [:md5], :unique => true
add_column :store_files, :provider, :string, :limit => 20, :null => true
add_index :store_files, [:provider]
Store::File.all.each {|file|
if file.data
file.update_attribute( :provider, 'DB' )
Store::Provider::DB.add( file.data, file.md5 )
else
file.update_attribute( :provider, 'File' )
Store::Provider::File.add( file.data, file.md5 )
end
}
remove_column :store_files, :data
end
def down
end
end

View file

@ -1,28 +0,0 @@
class UpdateStorage3 < ActiveRecord::Migration
def up
add_column :store_files, :sha, :string, :limit => 128, :null => true
add_index :store_files, [:sha], :unique => true
add_column :store_provider_dbs, :sha, :string, :limit => 128, :null => true
add_index :store_provider_dbs, [:sha], :unique => true
Store::File.all.each {|file|
next if file.sha
sha = Digest::SHA256.hexdigest( file.content )
file.update_attribute( :sha, sha )
}
Store::Provider::DB.all.each {|file|
next if file.sha
sha = Digest::SHA256.hexdigest( file.data )
file.update_attribute( :sha, sha )
}
remove_column :store_files, :md5
remove_column :store_provider_dbs, :md5
end
def down
end
end