fulltext search
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class CreateSearchEnties < ActiveRecord::Migration[8.0]
|
||||
def up
|
||||
return unless adapter_name == 'PostgreSQL'
|
||||
|
||||
enable_extension 'btree_gin'
|
||||
|
||||
create_table :search_entries do |t|
|
||||
t.references :record, null: false, polymorphic: true, index: false
|
||||
t.bigint :account_id, null: false
|
||||
t.tsvector :tsvector, null: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :search_entries, %i[account_id tsvector], using: :gin, where: "record_type = 'Submitter'",
|
||||
name: 'index_search_entries_on_account_id_tsvector_submitter'
|
||||
add_index :search_entries, %i[account_id tsvector], using: :gin, where: "record_type = 'Submission'",
|
||||
name: 'index_search_entries_on_account_id_tsvector_submission'
|
||||
add_index :search_entries, %i[account_id tsvector], using: :gin, where: "record_type = 'Template'",
|
||||
name: 'index_search_entries_on_account_id_tsvector_template'
|
||||
add_index :search_entries, %i[record_id record_type], unique: true
|
||||
end
|
||||
|
||||
def down
|
||||
return unless adapter_name == 'PostgreSQL'
|
||||
|
||||
drop_table :search_entries
|
||||
|
||||
disable_extension 'btree_gin'
|
||||
end
|
||||
end
|
||||
+15
-1
@@ -10,8 +10,9 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_05_31_085328) do
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_06_03_105556) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "btree_gin"
|
||||
enable_extension "plpgsql"
|
||||
|
||||
create_table "access_tokens", force: :cascade do |t|
|
||||
@@ -256,6 +257,19 @@ ActiveRecord::Schema[8.0].define(version: 2025_05_31_085328) do
|
||||
t.index ["uid"], name: "index_oauth_applications_on_uid", unique: true
|
||||
end
|
||||
|
||||
create_table "search_entries", force: :cascade do |t|
|
||||
t.string "record_type", null: false
|
||||
t.bigint "record_id", null: false
|
||||
t.bigint "account_id", null: false
|
||||
t.tsvector "tsvector", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["account_id", "tsvector"], name: "index_search_entries_on_account_id_tsvector_submission", where: "((record_type)::text = 'Submission'::text)", using: :gin
|
||||
t.index ["account_id", "tsvector"], name: "index_search_entries_on_account_id_tsvector_submitter", where: "((record_type)::text = 'Submitter'::text)", using: :gin
|
||||
t.index ["account_id", "tsvector"], name: "index_search_entries_on_account_id_tsvector_template", where: "((record_type)::text = 'Template'::text)", using: :gin
|
||||
t.index ["record_id", "record_type"], name: "index_search_entries_on_record_id_and_record_type", unique: true
|
||||
end
|
||||
|
||||
create_table "submission_events", force: :cascade do |t|
|
||||
t.bigint "submission_id", null: false
|
||||
t.bigint "submitter_id"
|
||||
|
||||
Reference in New Issue
Block a user