Skip to content
Snippets Groups Projects
Unverified Commit 38a4833e authored by Sébastien Gaya's avatar Sébastien Gaya
Browse files

Communication::Website::PreviousLink

parent a8285432
No related branches found
No related tags found
No related merge requests found
# == Schema Information
#
# Table name: communication_website_previous_links
#
# id :uuid not null, primary key
# about_type :string not null
# link :string
# created_at :datetime not null
# updated_at :datetime not null
# about_id :uuid not null
# university_id :uuid not null, indexed
# website_id :uuid not null, indexed
#
# Indexes
#
# index_communication_website_previous_links_on_university_id (university_id)
# index_communication_website_previous_links_on_website_id (website_id)
#
# Foreign Keys
#
# fk_rails_e9646cce64 (university_id => universities.id)
# fk_rails_f389ba7d45 (website_id => communication_websites.id)
#
class Communication::Website::PreviousLink < ApplicationRecord
include Sanitizable
include WithUniversity
belongs_to :university
belongs_to :website, class_name: "Communication::Website"
belongs_to :about, polymorphic: true
before_validation :set_university, on: :create
private
def set_university
self.university_id = website.university_id
end
end
class CreateCommunicationWebsitePreviousLinks < ActiveRecord::Migration[7.0]
def change
create_table :communication_website_previous_links, id: :uuid do |t|
t.references :university, null: false, foreign_key: true, type: :uuid
t.references :website, null: false, foreign_key: { to_table: :communication_websites }, type: :uuid
t.references :about, null: false, polymorphic: true, index: false, type: :uuid
t.string :link
t.timestamps
end
end
end
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment