-
Notifications
You must be signed in to change notification settings - Fork 196
Open
Description
I have a data migration which uses RLS.run_per_tenant in order to handle the tenant_id, and it seems to work fine. I am currently having an issue though where the DataMigrate::DataSchemaMigration insertion seems to be happening outside of my ability to handle RLS.
Now that I think about it, I think what would be ideal here would be to track which tenants have had which data migrations run against them - is that possible? If not, is it possible to track which data migrations have been run on the database as normal? I think this would require running RLS.disable! somewhere.
IGNORE_NO_TENANTS=true rails db:migrate:with_data
Accessing database as Marina 1
== Data =======================================================================
== 20230602202919 AddRoles: migrating =========================================
WARNING: ROW LEVEL SECURITY DISABLED!
Accessing database as Marina 1
Accessing database as Marina 2
Accessing database as Marina 3
== 20230602202919 AddRoles: migrated (0.0563s) ================================
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::RaiseException: ERROR: RLS not set up!
HINT: Please set rls.tenant_id or set rls.disable to FALSE.
CONTEXT: PL/pgSQL function rls_disabled() line 5 at RAISE
Caused by:
ActiveRecord::StatementInvalid: PG::RaiseException: ERROR: RLS not set up!
HINT: Please set rls.tenant_id or set rls.disable to FALSE.
CONTEXT: PL/pgSQL function rls_disabled() line 5 at RAISE
Caused by:
PG::RaiseException: ERROR: RLS not set up!
HINT: Please set rls.tenant_id or set rls.disable to FALSE.
CONTEXT: PL/pgSQL function rls_disabled() line 5 at RAISE
Tasks: TOP => db:migrate:with_data
(See full trace by running task with --trace)
Metadata
Metadata
Assignees
Labels
No labels