Skip to content

Commit

Permalink
Merge pull request #129 from hathitrust/HT-3224-rename-db-tables-take-2
Browse files Browse the repository at this point in the history
HT-3224: Rename database tables
  • Loading branch information
aelkiss authored Dec 3, 2021
2 parents f9ef3a8 + fce630b commit 8d7fbb4
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions app/models/ht_approval_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

class HTApprovalRequest < ApplicationRecord
self.primary_key = "id"
self.table_name = "otis_approval_requests"

def self.expiration_date
Date.today - 1.week
end
Expand Down
2 changes: 2 additions & 0 deletions app/models/ht_contact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# Map of institution email contact and type
class HTContact < ApplicationRecord
self.table_name = "otis_contacts"

belongs_to :ht_institution, foreign_key: :inst_id, primary_key: :inst_id, required: true
belongs_to :ht_contact_type, foreign_key: :contact_type, primary_key: :id, required: true
scope :for_institution, ->(inst_id) { where(inst_id: inst_id).order(:contact_type) }
Expand Down
2 changes: 2 additions & 0 deletions app/models/ht_contact_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# Name and description for type of institution contact
class HTContactType < ApplicationRecord
self.table_name = "otis_contact_types"

validates :name, presence: true, uniqueness: true, allow_blank: false
validates :description, presence: true, allow_blank: false

Expand Down
2 changes: 2 additions & 0 deletions app/models/ht_log.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

class HTLog < ApplicationRecord
self.table_name = "otis_logs"

validates :model, presence: true
validates :objid, presence: true
validates :data, presence: true
Expand Down
2 changes: 2 additions & 0 deletions app/models/ht_registration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

class HTRegistration < ApplicationRecord
self.primary_key = "id"
self.table_name = "otis_registrations"

validates :id, uniqueness: true

belongs_to :ht_institution, foreign_key: :inst_id, primary_key: :inst_id, required: true
Expand Down
10 changes: 5 additions & 5 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
ActiveRecord::Schema.define(version: 0) do # rubocop:disable Metrics/BlockLength
# Tables only used by otis

create_table :ht_approval_requests do |t|
create_table :otis_approval_requests do |t|
t.string :approver
t.string :userid
t.timestamp :sent
Expand All @@ -27,25 +27,25 @@
t.text :token_hash
end

create_table :ht_logs do |t|
create_table :otis_logs do |t|
t.string :objid
t.string :model
t.timestamp :time
t.text :data
end

create_table :ht_contacts do |t|
create_table :otis_contacts do |t|
t.string :inst_id
t.integer :contact_type
t.string :email
end

create_table :ht_contact_types do |t|
create_table :otis_contact_types do |t|
t.string :name
t.text :description
end

create_table :ht_registrations do |t|
create_table :otis_registrations do |t|
t.string :inst_id
t.string :jira_ticket
t.string :name
Expand Down

0 comments on commit 8d7fbb4

Please sign in to comment.