From fd456a77af9b9dbd3f2de39d40121d6c29e7cfee Mon Sep 17 00:00:00 2001 From: phc Date: Wed, 27 Nov 2024 21:04:39 +0100 Subject: [PATCH] use primary key type --- .../templates/create_pg_search_documents.rb.erb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/pg_search/migration/templates/create_pg_search_documents.rb.erb b/lib/pg_search/migration/templates/create_pg_search_documents.rb.erb index 3d79ddbe..41494c35 100644 --- a/lib/pg_search/migration/templates/create_pg_search_documents.rb.erb +++ b/lib/pg_search/migration/templates/create_pg_search_documents.rb.erb @@ -1,9 +1,9 @@ class CreatePgSearchDocuments < ActiveRecord::Migration<%= migration_version %> def up say_with_time("Creating table for pg_search multisearch") do - create_table :pg_search_documents do |t| + create_table :pg_search_documents, id: primary_key_type do |t| t.text :content - t.belongs_to :searchable, polymorphic: true, index: true + t.belongs_to :searchable, polymorphic: true, index: true, type: primary_key_type t.timestamps null: false end end @@ -14,4 +14,11 @@ class CreatePgSearchDocuments < ActiveRecord::Migration<%= migration_version %> drop_table :pg_search_documents end end + + private + + def primary_key_type + config = Rails.configuration.generators + config.options[config.orm][:primary_key_type] || :primary_key + end end