full_search 0.4.9 → 0.4.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 834fb641e471174fd832f6c0e825d2486dbb94985e35f5ab95f5fc068c08ece1
4
- data.tar.gz: c5d19d2c11fdf7eaa95c2af1fdc2a39d2db9d170e248591e29bba107249f691e
3
+ metadata.gz: 5a941ba183d7dd00eead669ac8b534b4028b32bd1d991db16bc0318345266e14
4
+ data.tar.gz: 6b7709cd3c9816ee80d5033cca05d8867f6e35df9d73c4294485772c658bc779
5
5
  SHA512:
6
- metadata.gz: 7bd69680899b8b405d3de387d1c3eafbb3e98ce0b08f937f7a9cac5282e5cb32cd24b96e7c20019b470937c817f419d2094ca48e9e9dd2a1fc49b9a0502295d7
7
- data.tar.gz: 50f29a99547ce19b2a3c5098a992476dbd5b0423e6d251768a4ec355db482f81bd94b0e23e13e0008c671c8d35911e0394cd716cf278f1808de52f94f5daaa71
6
+ metadata.gz: 8cbd0bc9321c9de12c1bea7831ba58f1b7d447c61d9997fc9bdf4ea4dbcd3e4b5d79f559057048ebec79cfcc1c3102ebbd436c939a84dbf82289d13bf339e373
7
+ data.tar.gz: '069b642037b70d91c2f0afc4491ceebb9bfdd6f40a68bc74366813d77e563915293f4cdbe87c44dc9aa10c38eca92c462916e0bc174926436031bb87f4365e1c'
data/README.md CHANGED
@@ -237,6 +237,21 @@ end
237
237
 
238
238
  When disabled, you must run `bin/rails full_search:prepare` after every `db:schema:load` to recreate the indexes.
239
239
 
240
+ `full_search` also ensures FTS tables exist before `db:schema:dump` reads the database and after `db:schema:load` finishes, so virtual tables are never silently dropped from `schema.rb` when models are registered but their tables haven't been created yet (e.g. development with `eager_load = false`). These hooks are gated by two config options, both on by default:
241
+
242
+ ```ruby
243
+ FullSearch.configure do |config|
244
+ # Run full_search:prepare before db:schema:dump so every registered
245
+ # FTS table is present in sqlite_master when the dumper reads it.
246
+ config.auto_prepare_on_schema_dump = true
247
+
248
+ # Create any FTS tables missing from schema.rb after db:schema:load.
249
+ config.auto_prepare_after_schema_load = true
250
+ end
251
+ ```
252
+
253
+ Set either to `false` if you prefer to run `bin/rails full_search:prepare` manually.
254
+
240
255
  ### Rake tasks
241
256
 
242
257
  | Task | Description |
@@ -5,7 +5,8 @@ module FullSearch
5
5
  attr_accessor :auto_rebuild_schema, :stale_query_behavior, :lock_rebuilds,
6
6
  :default_async_reindex, :default_async_source_reindex,
7
7
  :default_tokenizer, :auto_rebuild_on_stale_query, :min_like_prefix_length,
8
- :dump_schema_virtual_tables, :auto_rebuild_missing_tables
8
+ :dump_schema_virtual_tables, :auto_rebuild_missing_tables,
9
+ :auto_prepare_on_schema_dump, :auto_prepare_after_schema_load
9
10
 
10
11
  def initialize
11
12
  @auto_rebuild_schema = false
@@ -18,6 +19,8 @@ module FullSearch
18
19
  @min_like_prefix_length = FullSearch::Constants::DEFAULT_MIN_LIKE_PREFIX_LENGTH
19
20
  @dump_schema_virtual_tables = true
20
21
  @auto_rebuild_missing_tables = false
22
+ @auto_prepare_on_schema_dump = true
23
+ @auto_prepare_after_schema_load = true
21
24
  end
22
25
  end
23
26
 
@@ -37,6 +37,8 @@ module FullSearch
37
37
  end
38
38
 
39
39
  def reindex!
40
+ return if FullSearch::Index.rebuild_if_needed!(self)
41
+
40
42
  FullSearch::Index.reindex_source_fields!(self)
41
43
  end
42
44
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FullSearch
4
- VERSION = "0.4.9"
4
+ VERSION = "0.4.11"
5
5
  end
@@ -16,6 +16,17 @@ FullSearch.configure do |config|
16
16
  # Bulk imports should use FullSearch.bulk_import(Model) { ... } to defer reindexing.
17
17
  config.default_async_source_reindex = true
18
18
 
19
+ # Ensure FTS tables exist before db:schema:dump reads the database, so
20
+ # virtual tables are never silently dropped from schema.rb. Set to false
21
+ # if you prefer to run `bin/rails full_search:prepare` manually before
22
+ # dumping the schema.
23
+ config.auto_prepare_on_schema_dump = true
24
+
25
+ # Create any FTS tables missing from schema.rb after db:schema:load.
26
+ # Set to false if you prefer to run `bin/rails full_search:prepare`
27
+ # manually after loading the schema.
28
+ config.auto_prepare_after_schema_load = true
29
+
19
30
  # Uncomment to exclude full_search virtual tables from db/schema.rb.
20
31
  # When false, you must run `bin/rails full_search:prepare` after db:schema:load.
21
32
  # config.dump_schema_virtual_tables = false
@@ -140,4 +140,43 @@ namespace :full_search do
140
140
  puts "[OK] All full_search indexes are healthy"
141
141
  end
142
142
  end
143
+
144
+ # Internal: ensure FTS tables exist before db:schema:dump reads
145
+ # sqlite_master. Gated by auto_prepare_on_schema_dump so apps that
146
+ # prefer manual control can opt out.
147
+ task auto_prepare_before_dump: :environment do
148
+ next unless FullSearch.config.auto_prepare_on_schema_dump
149
+
150
+ Rails.application.eager_load!
151
+ FullSearch.setup!
152
+ end
153
+
154
+ # Internal: create any FTS tables missing from schema.rb after
155
+ # db:schema:load. Gated by auto_prepare_after_schema_load.
156
+ task auto_prepare_after_load: :environment do
157
+ next unless FullSearch.config.auto_prepare_after_schema_load
158
+
159
+ Rails.application.eager_load!
160
+ FullSearch.setup!
161
+ end
162
+ end
163
+
164
+ # Ensure FTS tables exist before db:schema:dump reads sqlite_master,
165
+ # so virtual tables aren't silently dropped from schema.rb when models
166
+ # were registered but their FTS tables never got created (e.g. dev with
167
+ # eager_load off, or a fresh db:schema:load against an incomplete dump).
168
+ if Rake::Task.task_defined?("db:schema:dump")
169
+ Rake::Task["db:schema:dump"].enhance(["full_search:auto_prepare_before_dump"])
170
+ end
171
+
172
+ # Create any FTS tables missing from schema.rb after db:schema:load.
173
+ # schema.rb may be missing tables if it was dumped with
174
+ # auto_prepare_on_schema_dump = false, or if new searchable models were
175
+ # added since the last dump.
176
+ if Rake::Task.task_defined?("db:schema:load")
177
+ Rake::Task["db:schema:load"].enhance do
178
+ next unless FullSearch.config.auto_prepare_after_schema_load
179
+ Rails.application.eager_load!
180
+ FullSearch.setup!
181
+ end
143
182
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: full_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.9
4
+ version: 0.4.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben D'Angelo