Skip to content

Commit

Permalink
Migration fix, and model clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
dgcliff committed Jun 24, 2019
1 parent 1e36e41 commit fd08ad9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/models/minerva/assignment.rb
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Minerva
class Assignment < ApplicationRecord
belongs_to :interface, :class_name => 'Minerva::Interface', optional: true
belongs_to :interface, optional: true
end
end
14 changes: 7 additions & 7 deletions app/models/minerva/state.rb
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
module Minerva
class State < ApplicationRecord
belongs_to :assignment, :class_name => 'Minerva::Assignment'
belongs_to :status, :class_name => 'Minerva::Status'

belongs_to :assignment
belongs_to :status
belongs_to :role
belongs_to :work
belongs_to :user

belongs_to :creator, class_name: "Minerva::User"

before_destroy { |record| raise ActiveRecord::ReadOnlyRecord }

def readonly?
# allow the creation, you can also use a more complex condition to allow updates under certain conditions
new_record? ? false : true
new_record? ? false : true
end
end
end
12 changes: 6 additions & 6 deletions db/migrate/20181218183815_create_minerva_states.rb
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ def change
t.integer :user_id
t.integer :role_id
t.integer :work_id
t.integer :minerva_assignment_id
t.integer :minerva_status_id
t.integer :assignment_id
t.integer :status_id

t.timestamps
end
Expand All @@ -15,9 +15,9 @@ def change
add_index :minerva_states, :role_id
add_index :minerva_states, :work_id

add_foreign_key :minerva_states, :minerva_assignments, column: :minerva_assignment_id
add_index :minerva_states, :minerva_assignment_id
add_foreign_key :minerva_states, :minerva_statuses, column: :minerva_status_id
add_index :minerva_states, :minerva_status_id
add_foreign_key :minerva_states, :minerva_assignments, column: :assignment_id
add_index :minerva_states, :assignment_id
add_foreign_key :minerva_states, :minerva_statuses, column: :status_id
add_index :minerva_states, :status_id
end
end
2 changes: 1 addition & 1 deletion lib/minerva/version.rb
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Minerva
VERSION = '0.1.22'
VERSION = '0.1.23'
end

0 comments on commit fd08ad9

Please sign in to comment.