rails-paradedb 0.3.0 → 0.4.0
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 +4 -4
- data/CHANGELOG.md +9 -1
- data/lib/parade_db/migration_helpers.rb +111 -0
- data/lib/parade_db/search_methods.rb +0 -4
- data/lib/parade_db/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2dac52ada2e15357193301cb0b3cf68bd0ef593794f972907c7ebf67cfa468f8
|
|
4
|
+
data.tar.gz: 99f3e0a8d0b18c1641e07bfe0e7098b2f19843de8910caa73c891b4ae3f42b9c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 020ae66713435adf05815a48581f1793a47ce5fabc1fd1abb2667408c18f99435eb915dac14d78afd3b566166cde0deb83af5177caecb8c9382c2317f667a983
|
|
7
|
+
data.tar.gz: 66c366c60656a2f494aefd0c0b050ea6fb8bcc57e7f3d9be270a9dabe75745bbec12ec7561531196c17f71bc3e3c59769515c1b43bb43e7c2b3fe961433cecaa
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. The format
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.4.0] - 2026-04-09
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- Removed unnecessary validation from non-exact aggregate queries without `over()`
|
|
12
|
+
- `change` migrations now auto-reverse `create_paradedb_index` and `add_bm25_index`, while irreversible ParadeDB migration helpers raise explicit rollback errors
|
|
13
|
+
|
|
7
14
|
## [0.3.0] - 2026-03-23
|
|
8
15
|
|
|
9
16
|
### Removed
|
|
@@ -103,7 +110,8 @@ All notable changes to this project will be documented in this file. The format
|
|
|
103
110
|
- Schema dump/load round-trip for tokenizer configuration and index options
|
|
104
111
|
(including `target_segment_count`)
|
|
105
112
|
|
|
106
|
-
[Unreleased]: https://github.com/paradedb/rails-paradedb/compare/v0.
|
|
113
|
+
[Unreleased]: https://github.com/paradedb/rails-paradedb/compare/v0.4.0...HEAD
|
|
114
|
+
[0.4.0]: https://github.com/paradedb/rails-paradedb/releases/tag/v0.4.0
|
|
107
115
|
[0.3.0]: https://github.com/paradedb/rails-paradedb/releases/tag/v0.3.0
|
|
108
116
|
[0.2.0]: https://github.com/paradedb/rails-paradedb/releases/tag/v0.2.0
|
|
109
117
|
[0.1.0]: https://github.com/paradedb/rails-paradedb/releases/tag/v0.1.0
|
|
@@ -787,6 +787,41 @@ if defined?(ActiveRecord::ConnectionAdapters::AbstractAdapter)
|
|
|
787
787
|
ActiveRecord::ConnectionAdapters::AbstractAdapter.include(ParadeDB::MigrationHelpers)
|
|
788
788
|
end
|
|
789
789
|
|
|
790
|
+
if defined?(ActiveRecord::Migration)
|
|
791
|
+
module ParadeDB
|
|
792
|
+
module MigrationDSL
|
|
793
|
+
def create_paradedb_index(index_klass, if_not_exists: false)
|
|
794
|
+
connection.create_paradedb_index(index_klass, if_not_exists: if_not_exists)
|
|
795
|
+
end
|
|
796
|
+
|
|
797
|
+
def replace_paradedb_index(index_klass)
|
|
798
|
+
connection.replace_paradedb_index(index_klass)
|
|
799
|
+
end
|
|
800
|
+
|
|
801
|
+
def add_bm25_index(table, fields:, key_field:, name: nil, index_options: nil, if_not_exists: false)
|
|
802
|
+
connection.add_bm25_index(
|
|
803
|
+
table,
|
|
804
|
+
fields: fields,
|
|
805
|
+
key_field: key_field,
|
|
806
|
+
name: name,
|
|
807
|
+
index_options: index_options,
|
|
808
|
+
if_not_exists: if_not_exists
|
|
809
|
+
)
|
|
810
|
+
end
|
|
811
|
+
|
|
812
|
+
def remove_bm25_index(table, name: nil, if_exists: false)
|
|
813
|
+
connection.remove_bm25_index(table, name: name, if_exists: if_exists)
|
|
814
|
+
end
|
|
815
|
+
|
|
816
|
+
def reindex_bm25(table, name: nil, concurrently: false)
|
|
817
|
+
connection.reindex_bm25(table, name: name, concurrently: concurrently)
|
|
818
|
+
end
|
|
819
|
+
end
|
|
820
|
+
end
|
|
821
|
+
|
|
822
|
+
ActiveRecord::Migration.include(ParadeDB::MigrationDSL)
|
|
823
|
+
end
|
|
824
|
+
|
|
790
825
|
if defined?(ActiveRecord::SchemaDumper)
|
|
791
826
|
module ParadeDB
|
|
792
827
|
module SchemaDumperPatch
|
|
@@ -829,3 +864,79 @@ if defined?(ActiveRecord::SchemaDumper)
|
|
|
829
864
|
|
|
830
865
|
ActiveRecord::SchemaDumper.prepend(ParadeDB::SchemaDumperPatch)
|
|
831
866
|
end
|
|
867
|
+
|
|
868
|
+
if defined?(ActiveRecord::Migration::CommandRecorder)
|
|
869
|
+
module ParadeDB
|
|
870
|
+
module CommandRecorderPatch
|
|
871
|
+
%i[
|
|
872
|
+
create_paradedb_index
|
|
873
|
+
add_bm25_index
|
|
874
|
+
remove_bm25_index
|
|
875
|
+
replace_paradedb_index
|
|
876
|
+
reindex_bm25
|
|
877
|
+
].each do |method_name|
|
|
878
|
+
define_method(method_name) do |*args, &block|
|
|
879
|
+
record(method_name, args, &block)
|
|
880
|
+
end
|
|
881
|
+
ruby2_keywords(method_name)
|
|
882
|
+
end
|
|
883
|
+
|
|
884
|
+
private
|
|
885
|
+
|
|
886
|
+
def invert_create_paradedb_index(args)
|
|
887
|
+
index_klass, = args
|
|
888
|
+
compiled = resolve_paradedb_index_klass(index_klass).compiled_definition
|
|
889
|
+
remove_options = Hash.ruby2_keywords_hash(name: compiled.index_name, if_exists: true)
|
|
890
|
+
|
|
891
|
+
[:remove_bm25_index, [compiled.table_name, remove_options]]
|
|
892
|
+
end
|
|
893
|
+
|
|
894
|
+
def invert_add_bm25_index(args)
|
|
895
|
+
table, options = args
|
|
896
|
+
options = symbolize_options_hash(options)
|
|
897
|
+
|
|
898
|
+
remove_options = { if_exists: true }
|
|
899
|
+
remove_options[:name] = options[:name] if options[:name]
|
|
900
|
+
remove_options = Hash.ruby2_keywords_hash(remove_options)
|
|
901
|
+
|
|
902
|
+
[:remove_bm25_index, [table, remove_options]]
|
|
903
|
+
end
|
|
904
|
+
|
|
905
|
+
def invert_remove_bm25_index(_args)
|
|
906
|
+
raise ActiveRecord::IrreversibleMigration,
|
|
907
|
+
"remove_bm25_index is not automatically reversible. Use #up/#down or #reversible."
|
|
908
|
+
end
|
|
909
|
+
|
|
910
|
+
def invert_replace_paradedb_index(_args)
|
|
911
|
+
raise ActiveRecord::IrreversibleMigration,
|
|
912
|
+
"replace_paradedb_index is not automatically reversible. Use #up/#down or #reversible."
|
|
913
|
+
end
|
|
914
|
+
|
|
915
|
+
def invert_reindex_bm25(_args)
|
|
916
|
+
raise ActiveRecord::IrreversibleMigration,
|
|
917
|
+
"reindex_bm25 is not automatically reversible. Use #up/#down or #reversible."
|
|
918
|
+
end
|
|
919
|
+
|
|
920
|
+
def resolve_paradedb_index_klass(index_klass)
|
|
921
|
+
case index_klass
|
|
922
|
+
when String
|
|
923
|
+
index_klass.to_s.split("::").inject(Object) { |ctx, const_name| ctx.const_get(const_name) }
|
|
924
|
+
else
|
|
925
|
+
index_klass
|
|
926
|
+
end
|
|
927
|
+
rescue NameError
|
|
928
|
+
raise ParadeDB::InvalidIndexDefinition, "Unknown index class #{index_klass.inspect}"
|
|
929
|
+
end
|
|
930
|
+
|
|
931
|
+
def symbolize_options_hash(options)
|
|
932
|
+
return {} unless options.is_a?(Hash)
|
|
933
|
+
|
|
934
|
+
options.each_with_object({}) do |(key, value), memo|
|
|
935
|
+
memo[key.to_sym] = value
|
|
936
|
+
end
|
|
937
|
+
end
|
|
938
|
+
end
|
|
939
|
+
end
|
|
940
|
+
|
|
941
|
+
ActiveRecord::Migration::CommandRecorder.prepend(ParadeDB::CommandRecorderPatch)
|
|
942
|
+
end
|
|
@@ -397,10 +397,6 @@ module ParadeDB
|
|
|
397
397
|
|
|
398
398
|
def facets_agg(exact: nil, **named_aggregations)
|
|
399
399
|
validate_exact_option!(exact)
|
|
400
|
-
if exact == false
|
|
401
|
-
raise ArgumentError, "facets_agg(exact: false) requires with_agg so aggregation runs as a window function"
|
|
402
|
-
end
|
|
403
|
-
|
|
404
400
|
agg_specs = normalize_named_aggregation_specs(named_aggregations)
|
|
405
401
|
build_aggregation_query(agg_specs, exact: exact).execute
|
|
406
402
|
end
|
data/lib/parade_db/version.rb
CHANGED