All posts changed to post_type=3 while migration

Hi,

as described here Upgrade fails while migrating we’re currently upgrading from a very old installation of discourse to the current v2.3.2. We’ve recognized that all posts have been changed to post_type=3 while the migration-process.

We’ve seen that an old but updated migration-script causes this “destruction”.

https://github.com/discourse/discourse/blob/master/db/migrate/20150729150523_migrate_auto_close_posts.rb

It seems that it has to be this way to make the string-append work:

sql = "UPDATE posts SET action_code = 'autoclosed.enabled', post_type = 3 "
sql += "WHERE post_type = 2 AND ("
sql += strings.map { |s| "raw ~* #{ActiveRecord::Base.connection.quote(s)}" }.join(' OR ')
sql += ")"

The current migration-step produces this query/output:

== 20150729150523 MigrateAutoClosePosts: migrating ============================
-- execute("UPDATE posts SET action_code = 'autoclosed.enabled', post_type = 3 ")

Kind Regards
Sascha

2 Likes

@gerhard can you fix that migration and validate that our migrations are “frozen-strings”-compatible?

1 Like

Thanks for reporting that issue. Fixed in https://github.com/discourse/discourse/commit/a8cdd68518eafff4a9d955ed6f085994d50b0231

4 Likes