# 1 מתוך 16551 העלאות לא הועברו ל-S3. העברת S3 נכשלה עבור db 'default'

**URL:** https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772
**Category:** Self-hosting
**Tags:** cdn, s3
**Created:** [21 בפברואר,‏ 2023,‏ 11:56am UTC](https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772 "2023-02-21T11:56:04Z")
**Posts on this page:** 3
**Page:** 2

<div class="post-metadata">

### Author: ![pawelorzech](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pawelorzech/32/251878_2.png) [@pawelorzech](https://meta.discourse.org/u/pawelorzech)
#### Post date: [11 ביולי,‏ 2023,‏ 11:22am UTC](https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772/25 "2023-07-11T11:22:11Z")

</div>

Ok, so this issue has been now fixed! Here’s how I did it (with immense help of Artur from our forum)

In [to\_s3\_migration.rb](https://github.com/discourse/discourse/blob/main/lib/file_store/to_s3_migration.rb), I’ve changed this:

```plaintext
count = Upload.by_users.where("url NOT LIKE '#{base_url}%'").count
      if count > 0
        error_message =
          "#{count} of #{Upload.count} uploads are not migrated to S3. #{failure_message}"
        raise_or_log(error_message, should_raise)
        success = false
      end

```

To this:

```plaintext
count = Upload.by_users.where("url NOT LIKE '#{base_url}%'").count
      if count > 0
        failed_uploads = Upload.by_users.where("url NOT LIKE '#{base_url}%'")
        failed_ids = failed_uploads.map(&:id)
        failed_id_list = failed_ids.join(", ")
        error_message =
          "#{count} of #{Upload.count} uploads are not migrated to S3. \n List of failed IDs: \n #{failed_id_list}; #{failure_message}"
        raise_or_log(error_message, should_raise)
        success = false
      end

```

And then in rails console just destroyed problematic upload. Now I’ve got issue with

```plaintext
FileStore::ToS3MigrationError: 3 posts are not remapped to new S3 upload URL. S3 migration failed for db 'default'.

```

But I think I’ve encountered a bigger issue - assets after being compilation are not being uploaded to S3 bucket:

 ![Screenshot FtgHAnTj from Arc -- 2023-07-11 at 13.21.29@2x](https://global.discourse-cdn.com/meta/original/4X/3/2/0/320f2e98e56bf662b18162c2202291d71aa9bbbd.png)

There obviously should be asset folder but there are none. This is something that’s preventing me from putting CDN in front of it all, but I guess that’s another issue, for a different topic?

---

<div class="post-metadata">

### Author: ![pawelorzech](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pawelorzech/32/251878_2.png) [@pawelorzech](https://meta.discourse.org/u/pawelorzech)
#### Post date: [11 ביולי,‏ 2023,‏ 12:06pm UTC](https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772/26 "2023-07-11T12:06:15Z")

</div>

For files changed:

```plaintext
count = Post.where("cooked LIKE '%#{cdn_path}%'").count
      if count > 0
        failed_posts = Post.where("cooked LIKE '%#{cdn_path}%'")
        id_list = failed_posts.map(&:id).join(", ")
        error_message = "#{count} posts are not remapped to new S3 upload URL. \n List of failing posts: \n #{id_list} \n #{failure_message}"
        raise_or_log(error_message, should_raise)
        success = false
      end

```

to

```plaintext
count = Post.where("cooked LIKE '%#{cdn_path}%'").count
      if count > 0
        failed_posts = Post.where("cooked LIKE '%#{cdn_path}%'")
        failed_ids = failed_posts.map(&:id).join(", ")
        failed_id_list = failed_ids.join(", ")
        error_message = "#{count} posts are not remapped to new S3 upload URL. \n List of failing posts: \n #{failed_id_list} \n #{failure_message}"
        raise_or_log(error_message, should_raise)
        success = false
      end

```

Got myself three ID’s and then went into [https://example.com/p/ID](https://example.com/p/ID) and deleted it from UI. Then it went smoothly!

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [10 באוגוסט,‏ 2023,‏ 12:06pm UTC](https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772/27 "2023-08-10T12:06:30Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.

[Previous page](https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772.md?page=1)
