1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
5 class CreateKeepServices < ActiveRecord::Migration
6 include CurrentApiClient
10 create_table :keep_services do |t|
11 t.string :uuid, :null => false
12 t.string :owner_uuid, :null => false
13 t.string :modified_by_client_uuid
14 t.string :modified_by_user_uuid
15 t.datetime :modified_at
16 t.string :service_host
17 t.integer :service_port
18 t.boolean :service_ssl_flag
19 t.string :service_type
23 add_index :keep_services, :uuid, :unique => true
25 add_column :keep_disks, :keep_service_uuid, :string
27 KeepDisk.reset_column_information
31 KeepDisk.find_each do |k|
32 services["#{k[:service_host]}_#{k[:service_port]}_#{k[:service_ssl_flag]}"] = {
33 service_host: k[:service_host],
34 service_port: k[:service_port],
35 service_ssl_flag: k[:service_ssl_flag],
37 owner_uuid: k[:owner_uuid]
41 services.each do |k, v|
42 v['uuid'] = KeepService.create(v).uuid
45 KeepDisk.find_each do |k|
46 k.keep_service_uuid = services["#{k[:service_host]}_#{k[:service_port]}_#{k[:service_ssl_flag]}"]['uuid']
50 remove_column :keep_disks, :service_host
51 remove_column :keep_disks, :service_port
52 remove_column :keep_disks, :service_ssl_flag