diff --git a/db/migrate/20241030023153_add_subject_to_semantic_links.rb b/db/migrate/20241030023153_add_subject_to_semantic_links.rb new file mode 100644 index 0000000000..8da1a18a06 --- /dev/null +++ b/db/migrate/20241030023153_add_subject_to_semantic_links.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +# rails g migration AddSubjectToSemanticLinks subject:references{polymorphic} +# +# We want to add links to Exchanges as well as Variants. +# The word subject comes from the triple structure of the Semantic Web: +# +# Subject predicate object (variant has linke URL) +class AddSubjectToSemanticLinks < ActiveRecord::Migration[7.0] + def change + # We allow `null` until we filled the new columns with existing data. + add_reference :semantic_links, :subject, polymorphic: true, null: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 856aa02bbf..d8b2d37159 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2024_10_23_054951) do +ActiveRecord::Schema[7.0].define(version: 2024_10_30_023153) do # These are extensions that must be enabled in order to support this database enable_extension "pg_stat_statements" enable_extension "plpgsql" @@ -405,6 +405,9 @@ ActiveRecord::Schema[7.0].define(version: 2024_10_23_054951) do t.string "semantic_id", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.string "subject_type" + t.bigint "subject_id" + t.index ["subject_type", "subject_id"], name: "index_semantic_links_on_subject" t.index ["variant_id"], name: "index_semantic_links_on_variant_id" end