1 class CreateKeepServices < ActiveRecord::Migration
2 include CurrentApiClient
6 create_table :keep_services do |t|
7 t.string :uuid, :null => false
8 t.string :owner_uuid, :null => false
9 t.string :modified_by_client_uuid
10 t.string :modified_by_user_uuid
11 t.datetime :modified_at
12 t.string :service_host
13 t.integer :service_port
14 t.boolean :service_ssl_flag
15 t.string :service_type
19 add_index :keep_services, :uuid, :unique => true
21 add_column :keep_disks, :keep_service_uuid, :string
23 KeepDisk.reset_column_information
27 KeepDisk.find_each do |k|
28 services["#{k[:service_host]}_#{k[:service_port]}_#{k[:service_ssl_flag]}"] = {
29 service_host: k[:service_host],
30 service_port: k[:service_port],
31 service_ssl_flag: k[:service_ssl_flag],
33 owner_uuid: k[:owner_uuid]
37 services.each do |k, v|
38 v['uuid'] = KeepService.create(v).uuid
41 KeepDisk.find_each do |k|
42 k.keep_service_uuid = services["#{k[:service_host]}_#{k[:service_port]}_#{k[:service_ssl_flag]}"]['uuid']
46 remove_column :keep_disks, :service_host
47 remove_column :keep_disks, :service_port
48 remove_column :keep_disks, :service_ssl_flag