This project is archived and is in readonly mode.

#2751 ✓stale
Christoph Petschnig

[patch] SchemaDumper works bad with table_prefix

Reported by Christoph Petschnig | June 3rd, 2009 @ 02:30 PM | in 3.x

When setting ActiveRecord::Base.table_name_prefix or table_name_suffix, Rails will dump all tables found in the database (except schema_migrations). This is a little dangerous when you do ie. rake db:reset. IMHO, the convention should be to dump only tables with the set prefix and suffix.

Of course, there is ActiveRecord::SchemaDumper.ignore_tables, but it lets you only define a blacklist, which is cumbersome on prefixes. A prefix like 'abc' would need

ActiveRecord::SchemaDumper.ignore_tables = [ /^(?!abc)/ ]
which is advanced regex magic and maybe too complicated for beginners.

Therefore I propose adding ActiveRecord::SchemaDumper.dump_only_with_prefix and -suffix, where you can turn off the new default behaviour.

This also fixes a small bug, where the table name 'schema_migrations' is hard coded instead of being used through ActiveRecord::Migrator.schema_migrations_table_name.

Comments and changes to this ticket

  • Jeremy Kemper

    Jeremy Kemper May 4th, 2010 @ 06:48 PM

    • Milestone changed from 2.x to 3.x
  • Rohit Arondekar

    Rohit Arondekar October 9th, 2010 @ 04:04 AM

    • State changed from “new” to “stale”
    • Importance changed from “” to “”

    Marking ticket as stale. If this is still an issue please leave a comment with suggested changes, creating a patch with tests, rebasing an existing patch or just confirming the issue on a latest release or master/branches.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Referenced by

Pages