This project is archived and is in readonly mode.

#3523 open
Gavin Stark

MySQL adapter should not dump views as create table statements for db:schema:dump

Reported by Gavin Stark | November 30th, 2009 @ 07:14 PM

When using MySQL any existing view will be dumped as a create table. The attached patch excludes any view from being output as a table in schema.rb Without any schema support for creating views this seems like the most expected behavior.

Comments and changes to this ticket

  • Marshall Huss

    Marshall Huss December 1st, 2009 @ 02:49 AM

    • Tag cleared.

    +1 I've seen the same issue.

  • Gavin Stark

    Gavin Stark January 17th, 2010 @ 09:59 PM

    Here is a patch against rails master @ c6850d8361bbf288cf3adefd087cb9a4bc9c97bc

  • Gavin Stark

    Gavin Stark January 17th, 2010 @ 10:11 PM

    The bugmash instructions (for the Jan 2010 bugmash) state I should say: I've attached a patch. The patch "mysql_dumper_not_include_views.diff" is for Rails 2.3 and "mysql_dont_dump_views_as_tables_30_master.patch" is against master (3.0pre) at the commit noted above.

  • Gavin Stark

    Gavin Stark May 15th, 2010 @ 07:06 PM

    The patch mysql_dont_dump_views_as_tables_30_master.patch still passes all tests on rails master @ 3436fdfc12d58925e3d981e0afa61084ea34736c

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:38 PM

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

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:38 PM

    • State changed from “open” to “stale”
  • Daniel

    Daniel March 10th, 2011 @ 03:06 PM

    Could we reopen it as "still a problem" now that I'm commenting on it? I just got bit by this problem in 2.3.11.

  • Daniel

    Daniel March 18th, 2011 @ 01:26 PM

    • State changed from “stale” to “open”

    [state:open]

  • Gavin Stark

    Gavin Stark March 19th, 2011 @ 02:58 PM

    I have reimplemented the patch (with a test) against rails 3.0 master at 445241

  • Gavin Stark

    Gavin Stark March 19th, 2011 @ 03:02 PM

    Daniel, I have "worked around" my patch not being in ActiveRecord by creating config/initializers/schema_dumper.rb with:

    # We name all our views beginning with 'view_' and they can be excluded from the schema dump
    ActiveRecord::SchemaDumper.ignore_tables = [/view_.+/]
    

    If you keep a naming scheme for views, this will help.

  • barrye (at gmail)

    barrye (at gmail) March 19th, 2011 @ 03:19 PM

    +1 This is a real problem.

  • Daniel

    Daniel March 21st, 2011 @ 02:05 PM

    Thanks for the update, Gavin. I discovered the rails_sql_views gem, which is part of the ActiveWarehouse project, and it includes a fix for this problem as well. Here's a link:

    http://activewarehouse.rubyforge.org/rails_sql_views/

    Hopefully the Rails team will address this problem soon.

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>

Pages