Skip to content

Add multi-tenant support for materialized views #30

@niteshpurohit

Description

@niteshpurohit

Feature Request

Description:

Add support for multi-tenancy, allowing materialized views to be scoped to a specific tenant (e.g., by a schema name or a tenant ID column).

Use Case:

In SaaS applications, data is often partitioned by tenant. This feature would allow the gem to manage materialized views within each tenant's namespace or schema correctly.

Proposed Solution:

  • Allow an optional tenant_id or schema_name to be associated with a MatViewDefinition.
  • All operations (refreshing, querying) must be performed within the context of the correct tenant.
  • This may involve using Apartment or similar gems, or setting search_path in PostgreSQL.

RSpec Tests:

  • Set up two tenants (e.g., two schemas).
  • Create a view definition with the same name in each tenant.
  • Trigger a refresh for the view in tenant 1.
  • Verify that the view in tenant 1 is refreshed, but the view in tenant 2 is not.

Checklist:

  • I have searched for a similar feature request and didn't find any duplicates.
  • I have included all the required information.
  • I have tagged the issue with the label "enhancement".

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions