[backend] feat(multi-tenancy): add default tenant migration and foreign keys (#3505)#4979
Conversation
0455196 to
4f1acae
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/current #4979 +/- ##
=====================================================
+ Coverage 56.44% 56.48% +0.03%
- Complexity 4577 4582 +5
=====================================================
Files 1007 1008 +1
Lines 30172 30190 +18
Branches 2228 2229 +1
=====================================================
+ Hits 17032 17052 +20
+ Misses 12166 12164 -2
Partials 974 974 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ce04a49 to
10fc241
Compare
| // Add default tenant | ||
| statement.execute(addDefaultTenant.replace(DEFAULT_TENANT_ID, DEFAULT_TENANT_UUID)); | ||
| // Add deleted_at in tenants for soft delete | ||
| statement.execute("ALTER TABLE tenants ADD tenant_deleted_at TIMESTAMP WITH TIME ZONE;"); |
There was a problem hiding this comment.
question: Should it be included in the bean ?
|
|
||
| try (Statement statement = context.getConnection().createStatement()) { | ||
| // Add default tenant | ||
| statement.execute(addDefaultTenant.replace(DEFAULT_TENANT_ID, DEFAULT_TENANT_UUID)); |
There was a problem hiding this comment.
nitpick: Seems a lot easier to read with String.format
statement.execute(String.format("""
INSERT INTO tenants(tenant_id, tenant_name, tenant_description)
VALUES ('%s', 'First default tenant auto created to rename', 'First default tenant auto created to rename');
""", DEFAULT_TENANT_UUID));
| "agents", | ||
| "asset_agent_jobs", |
There was a problem hiding this comment.
question: Since an agent is linked to a asset, do we need to add the tenant link here ?
There was a problem hiding this comment.
Seen together and with JB, yes we need :)
| "custom_dashboards", | ||
| "datapacks", | ||
| "documents", | ||
| "executors", |
There was a problem hiding this comment.
question: Why not adding tenant on domains like attack pattern and kill chain phases ?
| "groups", | ||
| "import_mappers", | ||
| "injectors", | ||
| "injectors_contracts", |
There was a problem hiding this comment.
question: Why ? an injector contracts is linked direclty to an injector.
| "injects", | ||
| "kill_chain_phases", | ||
| "lessons_templates", | ||
| "organizations", |
There was a problem hiding this comment.
question: Mitigation ? Seams to be used by OpenCTI
There was a problem hiding this comment.
Add tenant id and create issue to delete the code
| "injects", | ||
| "kill_chain_phases", | ||
| "lessons_templates", | ||
| "organizations", |
There was a problem hiding this comment.
nitpick: I have the feeling that notification_rules should include a tenant field so that we can list them in the future when we build the notification center. To be confirmed.
bfe30eb to
ba174ba
Compare
Proposed changes
Testing Instructions
Related issues
Checklist