module PgPower::ConnectionAdapters::PostgreSQLAdapter::SchemaMethods
Provides methods to extend {ActiveRecord::ConnectionAdapters::PostgreSQLAdapter} to support schemas feature.
Public Instance Methods
create_schema(schema_name)
click to toggle source
Creates new schema in DB. @param [String] schema_name
# File lib/pg_power/connection_adapters/postgresql_adapter/schema_methods.rb, line 6 def create_schema(schema_name) ::PgPower::Tools.create_schema(schema_name) end
drop_schema(schema_name)
click to toggle source
Drops schema in DB. @param [String] schema_name
# File lib/pg_power/connection_adapters/postgresql_adapter/schema_methods.rb, line 12 def drop_schema(schema_name) ::PgPower::Tools.drop_schema(schema_name) end
move_table_to_schema(table, schema)
click to toggle source
Move table to another schema @param [String] table table name. Can be with schema prefix e.g. “demography.people” @param [String] schema schema where table should be moved to.
# File lib/pg_power/connection_adapters/postgresql_adapter/schema_methods.rb, line 19 def move_table_to_schema(table, schema) ::PgPower::Tools.move_table_to_schema(table, schema) end
tables_with_non_public_schema_tables(*args)
click to toggle source
Make method tables
return tables not only from public schema.
@note
Tables from public schema have no "public." prefix. It's done for compatibility with other libraries that relies on a table name. Tables from other schemas has appropriate prefix with schema name. See: https://github.com/TMXCredit/pg_power/pull/42
@return [Array<String>] table names
# File lib/pg_power/connection_adapters/postgresql_adapter/schema_methods.rb, line 32 def tables_with_non_public_schema_tables(*args) public_tables = tables_without_non_public_schema_tables(*args) non_public_tables = query(<<-SQL, 'SCHEMA').map { |row| row[0] } SELECT schemaname || '.' || tablename AS table FROM pg_tables WHERE schemaname NOT IN ('pg_catalog', 'information_schema', 'public') SQL public_tables + non_public_tables end