Skip to content

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
Co-authored-by: Ryan Krage <[email protected]>
  • Loading branch information
rkrage and Ryan Krage committed Sep 25, 2023
1 parent b9cd300 commit 26cad76
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions lib/pg_ha_migrations/relation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def ==(other)
end

class Table < Relation
def self.from_table_name(table)
def self.from_table_name(table, mode=nil)
pg_name = ActiveRecord::ConnectionAdapters::PostgreSQL::Utils.extract_schema_qualified_name(table.to_s)

schema_conditional = if pg_name.schema
Expand All @@ -63,11 +63,7 @@ def self.from_table_name(table)

raise UndefinedTableError, "Table #{pg_name.quoted} does not exist#{" in search path" unless pg_name.schema}" unless schema.present?

new(pg_name.identifier, schema)
end

def self.from_table_name_with_lock(table, mode)
from_table_name(table).tap { |table| table.mode = mode }
new(pg_name.identifier, schema, mode)
end

def natively_partitioned?
Expand Down
2 changes: 1 addition & 1 deletion lib/pg_ha_migrations/safe_statements.rb
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ def safely_acquire_lock_for_table(table, mode: :access_exclusive, &block)

_check_postgres_adapter!

targeted_table = PgHaMigrations::Table.from_table_name_with_lock(table, mode)
targeted_table = PgHaMigrations::Table.from_table_name(table, mode)

if nested_targeted_table
if nested_targeted_table != targeted_table
Expand Down

0 comments on commit 26cad76

Please sign in to comment.