It is straightforward to ignore tables when your schema format is :ruby
, but is there a way to do it when your schema format is :sql
?
Ideally something like this in environment.rb
:
ActiveRecord::SQLDumper.ignore_tables = ['table_name']
After a quick perusal through the AR source code it looks unpromising.
1 Answers
Answers 1
There is currently no way to do this, when the schema format is set to :sql
, Rails doesn't go through the regular SchemaDumper
but instead uses the tasks in ActiveRecord::Tasks::PostgreSQLDatabaseTasks
to do the dump, check it out here.
The code is quite straightforward. I came up with a simple patch for ActiveRecord
that should work as expected. It relies on setting the tables to ignore in your database.yml
file. It basically adds the following code:
ignore_tables = configuration['ignore_tables'] unless ignore_tables.blank? args += ignore_tables.split(',').map do |table| "-T #{table}" end end
I just submitted a pull request to rails with those changes. In case you'd want to test it.
0 comments:
Post a Comment