# All posts changed to post\_type=3 while migration

**URL:** https://meta.discourse.org/t/all-posts-changed-to-post-type-3-while-migration/123404
**Category:** Bug
**Created:** [July 19, 2019, 11:37am UTC](https://meta.discourse.org/t/all-posts-changed-to-post-type-3-while-migration/123404 "2019-07-19T11:37:52Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![klopsknoedel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/klopsknoedel/32/194126_2.png) [@klopsknoedel](https://meta.discourse.org/u/klopsknoedel)
#### Post date: [July 19, 2019, 11:37am UTC](https://meta.discourse.org/t/all-posts-changed-to-post-type-3-while-migration/123404/1 "2019-07-19T11:37:52Z")

</div>

Hi,

as described here [Upgrade fails while migrating](https://meta.discourse.org/t/upgrade-fails-while-migrating/121894) 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/main/db/migrate/20150729150523_migrate_auto_close_posts.rb>

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

```ruby
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:

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

```

Kind Regards  
Sascha

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [July 22, 2019, 5:00pm UTC](https://meta.discourse.org/t/all-posts-changed-to-post-type-3-while-migration/123404/2 "2019-07-22T17:00:18Z")

</div>

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

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [July 22, 2019, 8:17pm UTC](https://meta.discourse.org/t/all-posts-changed-to-post-type-3-while-migration/123404/4 "2019-07-22T20:17:58Z")

</div>

Thanks for reporting that issue. Fixed in [FIX: Migrations tried to change frozen string · discourse/discourse@a8cdd68 · GitHub](https://github.com/discourse/discourse/commit/a8cdd68518eafff4a9d955ed6f085994d50b0231)

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [July 22, 2019, 8:18pm UTC](https://meta.discourse.org/t/all-posts-changed-to-post-type-3-while-migration/123404/5 "2019-07-22T20:18:37Z")

</div>


