Add relation between Goal and LocalTarget

This is similar to what we do with investments, which belong to a heading
but also belong to a budget. In our case, the reason is we've been asked
to add local targets which belong to a goal but are not related to any
existing target.
Even though we're not implementing that case right now, we're adding the
relation so we don't have to add data migrations in the future.
This commit is contained in:
taitus
2021-01-23 13:45:36 +01:00
parent cb57a4696d
commit 0a3de68206
6 changed files with 28 additions and 4 deletions

View File

@@ -0,0 +1,5 @@
class AddGoalsToLocalTargets < ActiveRecord::Migration[5.2]
def change
add_reference :sdg_local_targets, :goal
end
end

View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_01_07_125458) do
ActiveRecord::Schema.define(version: 2021_01_23_100638) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_trgm"
@@ -1322,7 +1322,9 @@ ActiveRecord::Schema.define(version: 2021_01_07_125458) do
t.string "code"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "goal_id"
t.index ["code"], name: "index_sdg_local_targets_on_code", unique: true
t.index ["goal_id"], name: "index_sdg_local_targets_on_goal_id"
t.index ["target_id"], name: "index_sdg_local_targets_on_target_id"
end