diff --git a/app/controllers/api/templates_controller.rb b/app/controllers/api/templates_controller.rb index 98815000..3ba50a89 100644 --- a/app/controllers/api/templates_controller.rb +++ b/app/controllers/api/templates_controller.rb @@ -8,6 +8,7 @@ module Api templates = Templates.search(@templates, params[:q]) templates = params[:archived] ? templates.archived : templates.active + templates = templates.where(application_key: params[:application_key]) if params[:application_key].present? templates = paginate(templates.preload(:author, documents_attachments: :blob)) diff --git a/app/models/template.rb b/app/models/template.rb index e1d4fbb9..0259a76c 100644 --- a/app/models/template.rb +++ b/app/models/template.rb @@ -4,19 +4,20 @@ # # Table name: templates # -# id :bigint not null, primary key -# deleted_at :datetime -# fields :text not null -# name :string not null -# schema :text not null -# slug :string not null -# source :text not null -# submitters :text not null -# created_at :datetime not null -# updated_at :datetime not null -# account_id :bigint not null -# author_id :bigint not null -# folder_id :bigint not null +# id :bigint not null, primary key +# application_key :string +# deleted_at :datetime +# fields :text not null +# name :string not null +# schema :text not null +# slug :string not null +# source :text not null +# submitters :text not null +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# author_id :bigint not null +# folder_id :bigint not null # # Indexes # diff --git a/db/migrate/20231017213639_add_application_id_to_submitters.rb b/db/migrate/20231017213639_add_application_key_to_submitters.rb similarity index 61% rename from db/migrate/20231017213639_add_application_id_to_submitters.rb rename to db/migrate/20231017213639_add_application_key_to_submitters.rb index 245c97ee..a772932d 100644 --- a/db/migrate/20231017213639_add_application_id_to_submitters.rb +++ b/db/migrate/20231017213639_add_application_key_to_submitters.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddApplicationIdToSubmitters < ActiveRecord::Migration[7.0] +class AddApplicationKeyToSubmitters < ActiveRecord::Migration[7.0] def change add_column :submitters, :application_key, :string end diff --git a/db/migrate/20231102171817_add_application_key_to_templates.rb b/db/migrate/20231102171817_add_application_key_to_templates.rb new file mode 100644 index 00000000..eaca3498 --- /dev/null +++ b/db/migrate/20231102171817_add_application_key_to_templates.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddApplicationKeyToTemplates < ActiveRecord::Migration[7.0] + def change + add_column :templates, :application_key, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index fb0adfef..512178c1 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: 2023_10_17_213639) do +ActiveRecord::Schema[7.0].define(version: 2023_11_02_171817) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -173,6 +173,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_10_17_213639) do t.datetime "updated_at", null: false t.text "source", null: false t.bigint "folder_id", null: false + t.string "application_key" t.index ["account_id"], name: "index_templates_on_account_id" t.index ["author_id"], name: "index_templates_on_author_id" t.index ["folder_id"], name: "index_templates_on_folder_id"