diff --git a/app/models/backup_library.rb b/app/models/backup_library.rb index ae5d740d9..f752810ca 100644 --- a/app/models/backup_library.rb +++ b/app/models/backup_library.rb @@ -1,3 +1,2 @@ class BackupLibrary < ActiveRecord::Base - self.table_name = 'backup_libraries' end diff --git a/app/models/backup_location.rb b/app/models/backup_location.rb index a59a39461..b4344cef6 100644 --- a/app/models/backup_location.rb +++ b/app/models/backup_location.rb @@ -1,4 +1,3 @@ class BackupLocation < ActiveRecord::Base - belongs_to :backup_library, foreign_key: :library_id - self.table_name = 'backup_locations' + belongs_to :backup_library end diff --git a/db/migrate/20200128220027_change_location_short_code.rb b/db/migrate/20200128220027_change_location_short_code.rb index d8b8093bf..6443f36cc 100644 --- a/db/migrate/20200128220027_change_location_short_code.rb +++ b/db/migrate/20200128220027_change_location_short_code.rb @@ -58,14 +58,17 @@ class ChangeLocationShortCode < ActiveRecord::Migration } def up + add_column :locations, :old_short_code, :string CODES.each do |old_code,new_code| entry = Location.find_or_initialize_by(short_code: old_code) entry.short_code = new_code + entry.old_short_code = old_code entry.save end end def down + remove_column :locations, :old_short_code CODES.invert.each do |old_code,new_code| entry = Location.find_or_initialize_by(short_code: old_code) entry.short_code = new_code diff --git a/db/schema.rb b/db/schema.rb index e92b7c6ca..0d07c3d2b 100755 --- a/db/schema.rb +++ b/db/schema.rb @@ -72,12 +72,13 @@ end create_table "locations", force: :cascade do |t| - t.string "short_code", limit: 255 - t.string "name", limit: 255 - t.string "url", limit: 255 - t.integer "library_id", limit: 4 - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.string "short_code", limit: 255 + t.string "name", limit: 255 + t.string "url", limit: 255 + t.integer "library_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "old_short_code", limit: 255 end add_index "locations", ["library_id"], name: "index_locations_on_library_id", using: :btree diff --git a/lib/generators/symphony_nightly/templates/update_symphony_nightly.erb b/lib/generators/symphony_nightly/templates/update_symphony_nightly.erb index cf1e7ef8b..fdc9b3c69 100644 --- a/lib/generators/symphony_nightly/templates/update_symphony_nightly.erb +++ b/lib/generators/symphony_nightly/templates/update_symphony_nightly.erb @@ -89,6 +89,7 @@ class UpdateSymphonyNightly<%= Time.now.strftime('%Y%m%d') %> < ActiveRecord::Mi end create_table :backup_locations do |t| t.string :short_code + t.string :old_short_code t.string :name t.string :url t.references :backup_library, index: true, foreign_key: true @@ -139,6 +140,7 @@ class UpdateSymphonyNightly<%= Time.now.strftime('%Y%m%d') %> < ActiveRecord::Mi def create_table_locations create_table :locations do |t| t.string :short_code + t.string :old_short_code t.string :name t.string :url t.references :library, index: true, foreign_key: true