Class: PgHaMigrations::PartmanTable

Inherits:
Table show all
Defined in:
lib/pg_ha_migrations/relation.rb

Constant Summary collapse

IDENTIFIER_REGEX =
/^[a-z_][a-z_\d]*$/

Instance Attribute Summary

Attributes inherited from Relation

#mode, #name, #schema

Instance Method Summary collapse

Methods inherited from Table

#check_constraints, from_table_name, #has_rows?, #natively_partitioned?, #partitions, #total_bytes

Methods inherited from Relation

#==, #conflicts_with?, connection, #eql?, #hash, #present?

Constructor Details

#initialize(name, schema, mode = nil) ⇒ PartmanTable

Returns a new instance of PartmanTable.



145
146
147
148
149
150
151
152
153
154
155
# File 'lib/pg_ha_migrations/relation.rb', line 145

def initialize(name, schema, mode=nil)
  if name !~ IDENTIFIER_REGEX
    raise InvalidIdentifierError, "Partman requires table names to be lowercase with underscores"
  end

  if schema !~ IDENTIFIER_REGEX
    raise InvalidIdentifierError, "Partman requires schema names to be lowercase with underscores"
  end

  super
end

Instance Method Details

#fully_qualified_nameObject



157
158
159
# File 'lib/pg_ha_migrations/relation.rb', line 157

def fully_qualified_name
  "#{schema}.#{name}"
end

#part_config(partman_extension:) ⇒ Object



161
162
163
# File 'lib/pg_ha_migrations/relation.rb', line 161

def part_config(partman_extension:)
  PgHaMigrations::PartmanConfig.find(fully_qualified_name, partman_extension: partman_extension)
end