4 changed files with 38 additions and 5 deletions
@ -0,0 +1,7 @@
|
||||
class AddForeignKeyToUserOrganisation < ActiveRecord::Migration[7.0] |
||||
|
||||
def change |
||||
add_reference :organisations, :users, foreign_key: true, on_delete: :cascade |
||||
end |
||||
end |
||||
|
@ -0,0 +1,6 @@
|
||||
class AddForeignKeyToLogsOrganisation < ActiveRecord::Migration[7.0] |
||||
|
||||
def change |
||||
add_reference :organisations, :case_logs, foreign_key: true, on_delete: :cascade |
||||
end |
||||
end |
@ -0,0 +1,20 @@
|
||||
class AddRelationshipsForOrganization < ActiveRecord::Migration[7.0] |
||||
|
||||
class Organisation < ApplicationRecord |
||||
has_many :users, dependent: :destroy |
||||
has_many :case_logs, dependent: :destroy |
||||
has_many :schemes, dependent: :destroy |
||||
end |
||||
|
||||
class User < ApplicationRecord |
||||
belongs_to :organization |
||||
end |
||||
|
||||
class CaseLog < ApplicationRecord |
||||
belongs_to :organization |
||||
end |
||||
|
||||
class CaseLog < ApplicationRecord |
||||
belongs_to :organization |
||||
end |
||||
end |
Loading…
Reference in new issue