Skip to content

Commit 48102ef

Browse files
committed
Update schema.create options
1 parent 72c9963 commit 48102ef

File tree

3 files changed

+13
-29
lines changed

3 files changed

+13
-29
lines changed

README.md

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -354,25 +354,7 @@ client.ready?
354354

355355
### Tenants
356356

357-
Any schema can be multi-tenant
358-
359-
```ruby
360-
client.schema.create(
361-
# Other keys...
362-
multi_tenant: true, # passes { enabled: true } to weaviate
363-
)
364-
```
365-
366-
You can also manually specify your multi tenancy configuration with a hash
367-
368-
```ruby
369-
client.schema.create(
370-
# Other keys...
371-
multi_tenant: { enabled: true, autoTenantCreation: true, autoTenantActivation: true },
372-
)
373-
```
374-
375-
Added shortcuts for `multiTenancyConfig`:
357+
Any schema can be multi-tenant by passing in these options for to `schema.create()`.
376358

377359
```ruby
378360
client.schema.create(

lib/weaviate/schema.rb

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ def create(
2626
class_name:,
2727
description: nil,
2828
properties: nil,
29-
multi_tenant: nil,
30-
auto_tenant_creation: nil,
31-
auto_tenant_activation: nil,
29+
multi_tenant: false,
30+
auto_tenant_creation: false,
31+
auto_tenant_activation: false,
3232
vector_index_type: nil,
3333
vector_index_config: nil,
3434
vectorizer: nil,
@@ -45,13 +45,15 @@ def create(
4545
req.body["vectorizer"] = vectorizer unless vectorizer.nil?
4646
req.body["moduleConfig"] = module_config unless module_config.nil?
4747
req.body["properties"] = properties unless properties.nil?
48-
if multi_tenant.is_a?(Hash)
49-
req.body["multiTenancyConfig"] = multi_tenant
50-
elsif !multi_tenant.nil?
51-
req.body["multiTenancyConfig"] = { enabled: true }
52-
req.body["multiTenancyConfig"].merge!(autoTenantCreation: true) unless auto_tenant_creation.nil?
53-
req.body["multiTenancyConfig"].merge!(autoTenantActivation: true) unless auto_tenant_activation.nil?
48+
49+
if multi_tenant
50+
req.body["multiTenancyConfig"] = {
51+
enabled: multi_tenant,
52+
autoTenantCreation: auto_tenant_creation,
53+
autoTenantActivation: auto_tenant_activation
54+
}
5455
end
56+
5557
req.body["invertedIndexConfig"] = inverted_index_config unless inverted_index_config.nil?
5658
req.body["replicationConfig"] = replication_config unless replication_config.nil?
5759
end

spec/weaviate/schema_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
auto_tenant_activation: true
9999
)
100100

101-
expect(@captured_request.body["multiTenancyConfig"]).to eq({ enabled: true, autoTenantCreation: true, autoTenantActivation: true })
101+
expect(@captured_request.body["multiTenancyConfig"]).to eq({enabled: true, autoTenantCreation: true, autoTenantActivation: true})
102102
end
103103
end
104104
end

0 commit comments

Comments
 (0)