diff --git a/app/views/admin/job_templates/index.html.haml b/app/views/admin/job_templates/index.html.haml index 0b3c9fbc8..8d7bee11b 100644 --- a/app/views/admin/job_templates/index.html.haml +++ b/app/views/admin/job_templates/index.html.haml @@ -15,7 +15,7 @@ - CropJobTemplate.statuses.each_key do |status| %li.nav-item = link_to crop_job_option(:status, status), admin_job_templates_path(status:), - class: "nav-link #{'active' if @status == status}" + class: "nav-link #{'active' if @status == status}" - if @templates.empty? %p No job templates here. diff --git a/db/migrate/20261024100000_add_creator_to_crop_job_templates.rb b/db/migrate/20261024100000_add_creator_to_crop_job_templates.rb new file mode 100644 index 000000000..838f78432 --- /dev/null +++ b/db/migrate/20261024100000_add_creator_to_crop_job_templates.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +# Who wrote a crop job template. Templates loaded from the seed files have none. +class AddCreatorToCropJobTemplates < ActiveRecord::Migration[8.1] + def change + add_reference :crop_job_templates, :creator, foreign_key: { to_table: :members } + end +end diff --git a/db/schema.rb b/db/schema.rb index 1495adfe2..fba27bc35 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[8.1].define(version: 2026_10_24_031447) do +ActiveRecord::Schema[8.1].define(version: 2026_10_24_100000) do # These are extensions that must be enabled in order to support this database enable_extension "pg_catalog.plpgsql" enable_extension "pg_trgm" @@ -550,6 +550,8 @@ ActiveRecord::Schema[8.1].define(version: 2026_10_24_031447) do t.string "season", default: "any", null: false t.string "status", default: "draft", null: false t.datetime "updated_at", null: false + t.bigint "creator_id" + t.index ["creator_id"], name: "index_crop_job_templates_on_creator_id" t.index ["crop_id"], name: "index_crop_job_templates_on_crop_id" end @@ -1109,6 +1111,7 @@ ActiveRecord::Schema[8.1].define(version: 2026_10_24_031447) do add_foreign_key "crop_dismissals", "members" add_foreign_key "crop_job_steps", "crop_job_templates" add_foreign_key "crop_job_templates", "crops" + add_foreign_key "crop_job_templates", "members", column: "creator_id" add_foreign_key "harvests", "plantings" add_foreign_key "job_idea_dismissals", "members" add_foreign_key "jobs", "crop_job_steps", on_delete: :nullify