Module: PgParty::Hacks::PostgreSQLDatabaseTasks
- Defined in:
- lib/pg_party/hacks/postgresql_database_tasks.rb
Overview
We should really use ActiveRecord::SchemaDumper.ignore_tables but it appears there’s a bug in the code that generates the args for pg_dump. I believe we need to exclude based on the fully qualified name (or a pattern like *.table_name) but the Rails code does not do this and we need to hack into low-level methods.
Instance Method Summary collapse
Instance Method Details
#run_cmd(cmd, args, action) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/pg_party/hacks/postgresql_database_tasks.rb', line 11 def run_cmd(cmd, args, action) if action != "dumping" || !PgParty.config.schema_exclude_partitions return super end partitions = ActiveRecord::Base.connection.select_values(<<-SQL, "SCHEMA") SELECT CONCAT(pg_namespace.nspname, '.', child.relname) FROM pg_inherits JOIN pg_class parent ON pg_inherits.inhparent = parent.oid JOIN pg_class child ON pg_inherits.inhrelid = child.oid JOIN pg_namespace ON parent.relnamespace = pg_namespace.oid WHERE parent.relkind = 'p' SQL excluded_tables = partitions.flat_map { |table| ["-T", table] } super(cmd, args + excluded_tables, action) end |