#697 ✓not-applicable
Charles Brian Quinn

Planning: pretend option to show queries for Migrations

Reported by Charles Brian Quinn | December 6th, 2008 @ 10:06 AM

I'm here at MerbDay in Atlanta, and the question came up (3 times):

"Is there a way to run rake db:automigrate and see what it would do first - like a pretend option?"

I took a quick stab, and didn't quite finish, but wanted to post some planning if anyone wants to comment and provide feedback (or take over and finish it).

The current approach could be:

Implement another PretendAdapter that overrides the:

module DataMapper module Adapters

class Sqlite3Adapter < DataObjectsAdapter

  # OVERRIDE EXECUTE to print the statement
  # with bind values instead of doing
  # command.execute_non_query:
  def execute(statement, *bind_values)
    with_connection do |connection|
      command = connection.create_command(statement)
      # command.execute_non_query(*bind_values)
      puts "Executing statement: #{statement.inspect}" +
           bind_values.empty? ? "" : "with bind_values: #{bind_values.inspect}"

end end


Comments and changes to this ticket

  • Charles Brian Quinn

    Charles Brian Quinn December 6th, 2008 @ 10:07 AM

    Oops, use this class instead:

    class PretendAdapter < DataObjectsAdapter

    I overrode the sqlite3 adapter to test.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) December 6th, 2008 @ 01:56 PM

    • Tag changed from migrations to migrations, suggestion
    • State changed from “unconfirmed” to “not-applicable”

    Charles, I think that would be a fantastic option to allow. Would you mind mentioning it on the mailing list?

    We've recently started to cleanup the tickets list, and are currently planning to only use it to track bugs and patches so I'm marking this as not applicable. For more information on why, please see the following: http://datamapper.lighthouseapp....

    I'll respond to your mailing list post with more detail, but I would suggest also overriding each of the three DO subclasses, since they tend to generate slightly different DDL statements (although we try to stick as close to the ANSI spec as possible).

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

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

People watching this ticket