Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

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

#3523

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.

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

State: open
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Marshall Huss
    Marshall Huss
    • Tag cleared.

    +1 I've seen the same issue.

    December 1st, 2009 @ 02:49 AM

  2. Gavin Stark
    Gavin Stark

    Here is a patch against rails master @ c6850d8361bbf288cf3adefd087cb9a4bc9c97bc

    January 17th, 2010 @ 09:59 PM

  3. Gavin Stark
    Gavin Stark

    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.

    January 17th, 2010 @ 10:11 PM

  4. Gavin Stark
    Gavin Stark

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

    May 15th, 2010 @ 07:06 PM

  5. Santiago Pastorino
    Santiago Pastorino
    • 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.

    February 2nd, 2011 @ 04:38 PM

  6. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 04:38 PM

  7. Daniel
    Daniel

    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.

    March 10th, 2011 @ 03:06 PM

  8. Daniel
    Daniel
    • State changed from stale to open

    [state:open]

    March 18th, 2011 @ 01:26 PM

  9. Gavin Stark
    Gavin Stark

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

    March 19th, 2011 @ 02:58 PM

  10. Gavin Stark
    Gavin Stark

    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.

    March 19th, 2011 @ 03:02 PM

  11. barrye (at gmail)
    barrye (at gmail)

    +1 This is a real problem.

    March 19th, 2011 @ 03:19 PM

  12. Daniel
    Daniel

    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.

    March 21st, 2011 @ 02:05 PM