I have a migration that executes this against a mysql server:
ActiveRecord::Base.connection.execute("update 'comments' set 'slug' = NULL;")
The purpose of this statement is to remove the value of “slug” for each row.
The table has millions of rows in it and is very slow when using ruby to do something like Comment.each...
Is there a way to rewrite this query in a way that it is db agnostic OR at minimum works OK between MySQL and postgresql?
Thank you!
This generates the query
UPDATE "comments" SET "slug" = NULLYou can also do batch updates on scopes and conditions. For examples, you can have:
That would produce
UPDATE "comments" SET "slug" = NULL WHERE (some_attribute = 'some_value')