Skip to content

Commit

Permalink
cleanup default sequence name
Browse files Browse the repository at this point in the history
  • Loading branch information
rpbaltazar committed Feb 3, 2022
1 parent 0922157 commit 19f1e17
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/apartment/active_record/postgresql_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ module Apartment::PostgreSqlAdapterPatch
def default_sequence_name(table, _column)
res = super
schema_prefix = "#{Apartment::Tenant.current}."
default_tenant_prefix = "#{Apartment::Tenant.default_tenant}."

if res&.starts_with?(schema_prefix)
default_tenant_prefix = "#{Apartment::Tenant.default_tenant}."
# NOTE: Excluded models should always access the sequence from the default
# tenant schema
if excluded_model?(table)
res.sub!(schema_prefix, default_tenant_prefix) if schema_prefix != default_tenant_prefix
else
res.delete_prefix!(schema_prefix)
end
# NOTE: Excluded models should always access the sequence from the default
# tenant schema
if excluded_model?(table)
res.sub!(schema_prefix, default_tenant_prefix) if schema_prefix != default_tenant_prefix
return res
end

res.delete_prefix!(schema_prefix) if res&.starts_with?(schema_prefix)

res
end

Expand Down

0 comments on commit 19f1e17

Please sign in to comment.