How can I get the current version information from my backup?

As mentioned in the title, my VPS was attacked. I tried to get the current discourse version information by running ./discourse-doctor, but it failed.

Fortunately, I had downloaded a backup to my local machine.
How can I retrieve the current version information from this backup?
Thanks.

2 Likes

What problem are you trying to solve? You can restore the backup to any newer version.

4 Likes

I’m planning to reinstall the OS and then set up the previous version of Discourse to avoid any plugin compatibility issues.

By the way, if a VPS has been hacked, is it still possible to back up the discourse? I only have an automatic backup from a few days ago.

That depends on what state they left it in. You could try to go through the rails console:

cd /var/discourse 
./launcher enter app
discourse backup
cd public/backups/default
scp * user@destination.example.com:

Your backup filename has the format forumname-2025-05-22-151843-v20250521053324.tar.gz

The long string at the end is the latest migration that has been ran.

To find out which commit it belongs to,

cd /var/www/discourse
git blame db/migrate/20250521053324*

You will now see some output and the left column contains the commit hash.
This is the minimal commit your new forum should be at.

(Sometimes the commit belongs to a plugin, in that case use locate to find the plugin, cd into its directory and do the same git blame stanza)

8 Likes

I would recommend just updating to latest. It’s easiest, and there is no risk. If it doesn’t work, then you can go about following those excellent instructions to find the commit and restoring to that one (and are you also going to restore each of the plugins to some particular commit?).

1 Like

I attempted to perform a backup, but it failed. The output is as follows:

# cd /var/discourse/
/var/discourse# ./launcher enter app
x86_64 arch detected.
/var/www/discourse# discourse backup
Starting backup...
EXCEPTION: BackupRestore::OperationRunningError
/var/www/discourse/lib/backup_restore/backuper.rb:70:in `ensure_no_operation_is_running'
/var/www/discourse/lib/backup_restore/backuper.rb:22:in `run'
script/discourse:84:in `backup'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/thor-1.3.1/lib/thor/command.rb:28:in `run'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/thor-1.3.1/lib/thor.rb:527:in `dispatch'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/thor-1.3.1/lib/thor/base.rb:584:in `start'
script/discourse:290:in `<top (required)>'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli/exec.rb:58:in `load'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli/exec.rb:58:in `kernel_load'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli/exec.rb:23:in `run'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli.rb:451:in `exec'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli.rb:34:in `dispatch'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli.rb:28:in `start'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/exe/bundle:28:in `block in <top (required)>'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/exe/bundle:20:in `<top (required)>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
Deleting old backups...
Cleaning stuff up...
Removing '.tar' leftovers...
Marking backup as finished...
Notifying 'system' of the end of the backup...
Finished!
[FAILED]

Does this mean I won’t be able to perform a backup?

It thinks another backup is running. You might try rebooting the container and then trying.

Thank you for your advice.
I was able to successfully start the backup.
However, the process has been stuck at this point for about 20 minutes (see screenshot below). Is this normal?

Yes, this table can get very large because of a bug, see Clean up user_auth_token_logs?

If it becomes a problem then you could stop the backup, enter the rails console

rails c
UserAuthTokenLog.delete_all

and then restart the backup.

3 Likes

Thank you for your suggestion. I’ve successfully backed up the latest data.
In addition, since the OS has already been reinstalled, how can I restore the latest state directly using the app.yml and backup files? Is there any official documentation for this? Or do I need to go through the standard Docker installation process first, and then import the backup to restore everything?

By the way, when I tried to find out which commit my Discourse backup corresponds to, I got the following output. Any idea why that might be?

/var/www/discourse# git blame db/migrate/20240516145911*
fatal: no such path 'db/migrate/20240516145911*' in HEAD

This!

Spoiler: it belongs to the chat plugin.

root@testbeta:/var/www/discourse# locate 202405161459
/var/www/discourse/plugins/chat/db/migrate/20240516145911_update_user_options_for_thread_title_prompts.rb
root@testbeta:/var/www/discourse# cd plugins/chat/
root@testbeta:/var/www/discourse/plugins/chat# git blame db/migrate/20240516145911*
1 Like

Thank you very much!
I’m not quite sure :thinking:does this method generate a commit to the Discourse repository itself, rather than to the chat plugin? If so, could you explain the mechanism behind it?

It seems that I could follow this guide?
https://meta.discourse.org/t/restore-a-backup-from-the-command-line/

2 Likes

I tried the way you recommended, but ran into the following issue.
Would you mind taking a look and letting me know what might’ve gone wrong?

/var/www/discourse# locate 20240516145911
/shared/backups/default/discourse-2025-05-24-113557-v20240516145911.tar.gz
/var/www/discourse/plugins/chat/db/post_migrate/20240516145911_update_user_options_for_thread_title_prompts.rb
root@tartali-app:/var/www/discourse# cd plugins/chat/
root@tartali-app:/var/www/discourse/plugins/chat# git blame db/migrate/20240516145911*
fatal: no such path 'plugins/chat/db/migrate/20240516145911*' in HEAD```

Sorry. I got it by git blame db/post_migrate/20240516145911*

This is the output:

root@tartali-app:/var/www/discourse/plugins/chat# git blame db/post_migrate/20240516145911*
remote: Enumerating objects: 2571, done.
remote: Counting objects: 100% (422/422), done.
remote: Compressing objects: 100% (421/421), done.
remote: Total 2571 (delta 2), reused 1 (delta 1), pack-reused 2149 (from 1)
Receiving objects: 100% (2571/2571), 1008.42 KiB | 14.20 MiB/s, done.
Resolving deltas: 100% (2/2), done.
remote: Enumerating objects: 2571, done.
remote: Counting objects: 100% (405/405), done.
remote: Compressing objects: 100% (405/405), done.
Receiving objects: 100% (2571/2571), 1007.76 KiB | 21.91 MiB/s, done.
Resolving deltas: 100% (3/3), done.
remote: Total 2571 (delta 3), reused 0 (delta 0), pack-reused 2166 (from 1)
remote: Enumerating objects: 2571, done.
remote: Counting objects: 100% (413/413), done.
remote: Compressing objects: 100% (413/413), done.
Receiving objects: 100% (2571/2571), 1007.81 KiB | 22.90 MiB/s, done.
Resolving deltas: 100% (3/3), done.
remote: Total 2571 (delta 3), reused 0 (delta 0), pack-reused 2158 (from 1)
remote: Enumerating objects: 2571, done.
remote: Counting objects: 100% (413/413), done.
remote: Compressing objects: 100% (413/413), done.
remote: Total 2571 (delta 3), reused 0 (delta 0), pack-reused 2158 (from 1)
Receiving objects: 100% (2571/2571), 1007.82 KiB | 22.40 MiB/s, done.
Resolving deltas: 100% (3/3), done.
remote: Enumerating objects: 2571, done.
remote: Counting objects: 100% (413/413), done.
remote: Compressing objects: 100% (413/413), done.
remote: Total 2571 (delta 3), reused 0 (delta 0), pack-reused 2158 (from 1)
Receiving objects: 100% (2571/2571), 1007.81 KiB | 22.40 MiB/s, done.
Resolving deltas: 100% (3/3), done.
remote: Enumerating objects: 2571, done.
remote: Counting objects: 100% (405/405), done.
remote: Compressing objects: 100% (405/405), done.
Receiving objects: 100% (2571/2571), 1007.76 KiB | 22.39 MiB/s, done.
Resolving deltas: 100% (3/3), done.
remote: Total 2571 (delta 3), reused 0 (delta 0), pack-reused 2166 (from 1)
remote: Enumerating objects: 2571, done.
remote: Counting objects: 100% (405/405), done.
remote: Compressing objects: 100% (405/405), done.
Receiving objects: 100% (2571/2571), 1007.76 KiB | 22.39 MiB/s, done.
Resolving deltas: 100% (3/3), done.
remote: Total 2571 (delta 3), reused 0 (delta 0), pack-reused 2166 (from 1)
remote: Enumerating objects: 2571, done.
remote: Counting objects: 100% (413/413), done.
remote: Compressing objects: 100% (413/413), done.
Receiving objects: 100% (2571/2571), 1007.78 KiB | 23.44 MiB/s, done.
Resolving deltas: 100% (3/3), done.
remote: Total 2571 (delta 3), reused 0 (delta 0), pack-reused 2158 (from 1)
remote: Enumerating objects: 2571, done.
remote: Counting objects: 100% (422/422), done.
remote: Compressing objects: 100% (421/421), done.
remote: Total 2571 (delta 2), reused 1 (delta 1), pack-reused 2149 (from 1)
Receiving objects: 100% (2571/2571), 1008.39 KiB | 22.92 MiB/s, done.
Resolving deltas: 100% (2/2), done.
remote: Enumerating objects: 2571, done.
remote: Counting objects: 100% (422/422), done.
remote: Compressing objects: 100% (421/421), done.
remote: Total 2571 (delta 2), reused 1 (delta 1), pack-reused 2149 (from 1)
Receiving objects: 100% (2571/2571), 1008.39 KiB | 22.41 MiB/s, done.
Resolving deltas: 100% (2/2), done.
remote: Enumerating objects: 2571, done.
remote: Counting objects: 100% (404/404), done.
remote: Compressing objects: 100% (404/404), done.
remote: Total 2571 (delta 3), reused 0 (delta 0), pack-reused 2167 (from 1)
Receiving objects: 100% (2571/2571), 1007.74 KiB | 21.91 MiB/s, done.
Resolving deltas: 100% (3/3), done.
remote: Enumerating objects: 2571, done.
remote: Counting objects: 100% (422/422), done.
remote: Compressing objects: 100% (421/421), done.
remote: Total 2571 (delta 2), reused 1 (delta 1), pack-reused 2149 (from 1)
Receiving objects: 100% (2571/2571), 1008.40 KiB | 22.92 MiB/s, done.
Resolving deltas: 100% (2/2), done.
remote: Enumerating objects: 2571, done.
remote: Counting objects: 100% (422/422), done.
remote: Compressing objects: 100% (421/421), done.
remote: Total 2571 (delta 2), reused 1 (delta 1), pack-reused 2149 (from 1)
Receiving objects: 100% (2571/2571), 1008.39 KiB | 22.41 MiB/s, done.
Resolving deltas: 100% (2/2), done.
remote: Enumerating objects: 2571, done.
remote: Counting objects: 100% (414/414), done.
remote: Compressing objects: 100% (414/414), done.
Receiving objects: 100% (2571/2571), 1007.78 KiB | 22.90 MiB/s, done.
Resolving deltas: 100% (3/3), done.
remote: Total 2571 (delta 3), reused 0 (delta 0), pack-reused 2157 (from 1)
remote: Enumerating objects: 2571, done.
remote: Counting objects: 100% (403/403), done.
remote: Compressing objects: 100% (403/403), done.
remote: Total 2571 (delta 3), reused 0 (delta 0), pack-reused 2168 (from 1)
Receiving objects: 100% (2571/2571), 1007.66 KiB | 22.39 MiB/s, done.
Resolving deltas: 100% (3/3), done.
remote: Enumerating objects: 2571, done.
remote: Counting objects: 100% (413/413), done.
remote: Compressing objects: 100% (413/413), done.
remote: Total 2571 (delta 3), reused 0 (delta 0), pack-reused 2158 (from 1)
Receiving objects: 100% (2571/2571), 1007.70 KiB | 12.44 MiB/s, done.
Resolving deltas: 100% (3/3), done.
remote: Enumerating objects: 2571, done.
remote: Counting objects: 100% (412/412), done.
remote: Compressing objects: 100% (412/412), done.
remote: Total 2571 (delta 3), reused 0 (delta 0), pack-reused 2159 (from 1)
Receiving objects: 100% (2571/2571), 1007.71 KiB | 22.39 MiB/s, done.
Resolving deltas: 100% (3/3), done.
remote: Enumerating objects: 2571, done.
remote: Counting objects: 100% (419/419), done.
remote: Compressing objects: 100% (418/418), done.
remote: Total 2571 (delta 2), reused 1 (delta 1), pack-reused 2152 (from 1)
Receiving objects: 100% (2571/2571), 1008.31 KiB | 21.92 MiB/s, done.
Resolving deltas: 100% (2/2), done.
remote: Enumerating objects: 2571, done.
remote: Counting objects: 100% (404/404), done.
remote: Compressing objects: 100% (404/404), done.
remote: Total 2571 (delta 3), reused 0 (delta 0), pack-reused 2167 (from 1)
Receiving objects: 100% (2571/2571), 1007.66 KiB | 22.90 MiB/s, done.
Resolving deltas: 100% (3/3), done.
remote: Enumerating objects: 2571, done.
remote: Counting objects: 100% (414/414), done.
remote: Compressing objects: 100% (414/414), done.
remote: Total 2571 (delta 3), reused 0 (delta 0), pack-reused 2157 (from 1)
Receiving objects: 100% (2571/2571), 1007.70 KiB | 12.00 MiB/s, done.
Resolving deltas: 100% (3/3), done.
remote: Enumerating objects: 2571, done.
remote: Counting objects: 100% (412/412), done.
remote: Compressing objects: 100% (412/412), done.
remote: Total 2571 (delta 3), reused 0 (delta 0), pack-reused 2159 (from 1)
Receiving objects: 100% (2571/2571), 1007.70 KiB | 22.39 MiB/s, done.
Resolving deltas: 100% (3/3), done.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (416/416), done.
remote: Compressing objects: 100% (416/416), done.
Receiving objects: 100% (2569/2569), 1006.98 KiB | 22.89 MiB/s, done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2153 (from 1)
Resolving deltas: 100% (3/3), done.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (418/418), done.
remote: Compressing objects: 100% (417/417), done.
Receiving objects: 100% (2569/2569), 1007.58 KiB | 22.90 MiB/s, done.
remote: Total 2569 (delta 2), reused 1 (delta 1), pack-reused 2151 (from 1)
Resolving deltas: 100% (2/2), done.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (405/405), done.
remote: Compressing objects: 100% (405/405), done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2164 (from 1)
Receiving objects: 100% (2569/2569), 1006.90 KiB | 22.88 MiB/s, done.
Resolving deltas: 100% (3/3), done.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (417/417), done.
remote: Compressing objects: 100% (416/416), done.
remote: Total 2569 (delta 2), reused 1 (delta 1), pack-reused 2152 (from 1)
Receiving objects: 100% (2569/2569), 1007.75 KiB | 20.57 MiB/s, done.
Resolving deltas: 100% (2/2), done.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (417/417), done.
remote: Compressing objects: 100% (416/416), done.
remote: Total 2569 (delta 2), reused 1 (delta 1), pack-reused 2152 (from 1)
Receiving objects: 100% (2569/2569), 1007.74 KiB | 23.44 MiB/s, done.
Resolving deltas: 100% (2/2), done.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (417/417), done.
remote: Compressing objects: 100% (416/416), done.
remote: Total 2569 (delta 2), reused 1 (delta 1), pack-reused 2152 (from 1)
Receiving objects: 100% (2569/2569), 1007.55 KiB | 23.43 MiB/s, done.
Resolving deltas: 100% (2/2), done.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (417/417), done.
remote: Compressing objects: 100% (416/416), done.
remote: Total 2569 (delta 2), reused 1 (delta 1), pack-reused 2152 (from 1)
Receiving objects: 100% (2569/2569), 1007.56 KiB | 23.43 MiB/s, done.
Resolving deltas: 100% (2/2), done.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (418/418), done.
remote: Compressing objects: 100% (417/417), done.
remote: Total 2569 (delta 2), reused 1 (delta 1), pack-reused 2151 (from 1)
Receiving objects: 100% (2569/2569), 1007.56 KiB | 10.72 MiB/s, done.
Resolving deltas: 100% (2/2), done.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (405/405), done.
remote: Compressing objects: 100% (405/405), done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2164 (from 1)
Receiving objects: 100% (2569/2569), 1006.91 KiB | 22.38 MiB/s, done.
Resolving deltas: 100% (3/3), done.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (404/404), done.
remote: Compressing objects: 100% (404/404), done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2165 (from 1)
Receiving objects: 100% (2569/2569), 1006.90 KiB | 22.38 MiB/s, done.
Resolving deltas: 100% (3/3), done.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (404/404), done.
remote: Compressing objects: 100% (404/404), done.
Receiving objects: 100% (2569/2569), 1006.88 KiB | 22.88 MiB/s, done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2165 (from 1)
Resolving deltas: 100% (3/3), done.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (416/416), done.
remote: Compressing objects: 100% (416/416), done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2153 (from 1)
Receiving objects: 100% (2569/2569), 1006.89 KiB | 5.47 MiB/s, done.
Resolving deltas: 100% (3/3), done.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (415/415), done.
remote: Compressing objects: 100% (415/415), done.
Receiving objects: 100% (2569/2569), 1006.89 KiB | 22.88 MiB/s, done.
Resolving deltas: 100% (3/3), done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2154 (from 1)
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (415/415), done.
remote: Compressing objects: 100% (415/415), done.
Receiving objects: 100% (2569/2569), 1006.89 KiB | 21.42 MiB/s, done.
Resolving deltas: 100% (3/3), done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2154 (from 1)
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (416/416), done.
remote: Compressing objects: 100% (415/415), done.
remote: Total 2569 (delta 2), reused 1 (delta 1), pack-reused 2153 (from 1)
Receiving objects: 100% (2569/2569), 1007.50 KiB | 23.43 MiB/s, done.
Resolving deltas: 100% (2/2), done.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (405/405), done.
remote: Compressing objects: 100% (405/405), done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2164 (from 1)
Receiving objects: 100% (2569/2569), 1006.63 KiB | 13.98 MiB/s, done.
Resolving deltas: 100% (3/3), done.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (405/405), done.
remote: Compressing objects: 100% (405/405), done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2164 (from 1)
Receiving objects: 100% (2569/2569), 1006.63 KiB | 19.36 MiB/s, done.
Resolving deltas: 100% (3/3), done.
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (417/417), done.
remote: Compressing objects: 100% (416/416), done.
remote: Total 2569 (delta 2), reused 1 (delta 1), pack-reused 2152 (from 1)
Receiving objects: 100% (2569/2569), 1007.29 KiB | 15.50 MiB/s, done.
Resolving deltas: 100% (2/2), done.
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (405/405), done.
remote: Compressing objects: 100% (405/405), done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2164 (from 1)
Receiving objects: 100% (2569/2569), 1006.63 KiB | 16.50 MiB/s, done.
Resolving deltas: 100% (3/3), done.
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (405/405), done.
remote: Compressing objects: 100% (405/405), done.
Receiving objects: 100% (2569/2569), 1006.63 KiB | 22.37 MiB/s, done.
Resolving deltas: 100% (3/3), done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2164 (from 1)
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (417/417), done.
remote: Compressing objects: 100% (416/416), done.
remote: Total 2569 (delta 2), reused 1 (delta 1), pack-reused 2152 (from 1)
Receiving objects: 100% (2569/2569), 1007.29 KiB | 22.89 MiB/s, done.
Resolving deltas: 100% (2/2), done.
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (405/405), done.
remote: Compressing objects: 100% (405/405), done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2164 (from 1)
Receiving objects: 100% (2569/2569), 1006.63 KiB | 21.42 MiB/s, done.
Resolving deltas: 100% (3/3), done.
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (416/416), done.
remote: Compressing objects: 100% (416/416), done.
Receiving objects: 100% (2569/2569), 1006.67 KiB | 20.13 MiB/s, done.
Resolving deltas: 100% (3/3), done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2153 (from 1)
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (417/417), done.
remote: Compressing objects: 100% (416/416), done.
remote: Total 2569 (delta 2), reused 1 (delta 1), pack-reused 2152 (from 1)
Receiving objects: 100% (2569/2569), 1007.29 KiB | 21.43 MiB/s, done.
Resolving deltas: 100% (2/2), done.
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (416/416), done.
remote: Compressing objects: 100% (416/416), done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2153 (from 1)
Receiving objects: 100% (2569/2569), 1006.68 KiB | 21.88 MiB/s, done.
Resolving deltas: 100% (3/3), done.
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (415/415), done.
remote: Compressing objects: 100% (414/414), done.
Receiving objects: 100% (2569/2569), 1007.28 KiB | 23.42 MiB/s, done.
Resolving deltas: 100% (2/2), done.
remote: Total 2569 (delta 2), reused 1 (delta 1), pack-reused 2154 (from 1)
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (415/415), done.
remote: Compressing objects: 100% (415/415), done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2154 (from 1)
Receiving objects: 100% (2569/2569), 1006.68 KiB | 17.98 MiB/s, done.
Resolving deltas: 100% (3/3), done.
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (417/417), done.
remote: Compressing objects: 100% (416/416), done.
Receiving objects: 100% (2569/2569), 1007.29 KiB | 22.89 MiB/s, done.
Resolving deltas: 100% (2/2), done.
remote: Total 2569 (delta 2), reused 1 (delta 1), pack-reused 2152 (from 1)
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (404/404), done.
remote: Compressing objects: 100% (404/404), done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2165 (from 1)
Receiving objects: 100% (2569/2569), 1006.63 KiB | 20.54 MiB/s, done.
Resolving deltas: 100% (3/3), done.
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (416/416), done.
remote: Compressing objects: 100% (416/416), done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2153 (from 1)
Receiving objects: 100% (2569/2569), 1006.68 KiB | 22.88 MiB/s, done.
Resolving deltas: 100% (3/3), done.
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (404/404), done.
remote: Compressing objects: 100% (404/404), done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2165 (from 1)
Receiving objects: 100% (2569/2569), 1006.63 KiB | 19.74 MiB/s, done.
Resolving deltas: 100% (3/3), done.
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (415/415), done.
remote: Compressing objects: 100% (415/415), done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2154 (from 1)
Receiving objects: 100% (2569/2569), 1006.68 KiB | 14.18 MiB/s, done.
Resolving deltas: 100% (3/3), done.
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (416/416), done.
remote: Compressing objects: 100% (415/415), done.
Receiving objects: 100% (2569/2569), 1007.14 KiB | 22.89 MiB/s, done.
Resolving deltas: 100% (2/2), done.
remote: Total 2569 (delta 2), reused 1 (delta 1), pack-reused 2153 (from 1)
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (416/416), done.
remote: Compressing objects: 100% (416/416), done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2153 (from 1)
Receiving objects: 100% (2569/2569), 1006.54 KiB | 22.37 MiB/s, done.
Resolving deltas: 100% (3/3), done.
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (404/404), done.
remote: Compressing objects: 100% (404/404), done.
Receiving objects: 100% (2569/2569), 1006.49 KiB | 22.37 MiB/s, done.
Resolving deltas: 100% (3/3), done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2165 (from 1)
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (416/416), done.
remote: Compressing objects: 100% (416/416), done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2153 (from 1)
Receiving objects: 100% (2569/2569), 1006.53 KiB | 22.37 MiB/s, done.
Resolving deltas: 100% (3/3), done.
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (416/416), done.
remote: Compressing objects: 100% (416/416), done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2153 (from 1)
Receiving objects: 100% (2569/2569), 1006.53 KiB | 18.99 MiB/s, done.
Resolving deltas: 100% (3/3), done.
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (404/404), done.
remote: Compressing objects: 100% (404/404), done.
Receiving objects: 100% (2569/2569), 1006.51 KiB | 22.37 MiB/s, done.
Resolving deltas: 100% (3/3), done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2165 (from 1)
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (404/404), done.
remote: Compressing objects: 100% (404/404), done.
Receiving objects: 100% (2569/2569), 1006.51 KiB | 22.88 MiB/s, done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2165 (from 1)
Resolving deltas: 100% (3/3), done.
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (417/417), done.
remote: Compressing objects: 100% (417/417), done.
remote: Total 2569 (delta 2), reused 0 (delta 0), pack-reused 2152 (from 1)
Receiving objects: 100% (2569/2569), 1007.17 KiB | 13.80 MiB/s, done.
Resolving deltas: 100% (2/2), done.
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (416/416), done.
remote: Compressing objects: 100% (416/416), done.
Receiving objects: 100% (2569/2569), 1006.56 KiB | 22.88 MiB/s, done.
Resolving deltas: 100% (3/3), done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2153 (from 1)
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (416/416), done.
remote: Compressing objects: 100% (416/416), done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2153 (from 1)
Receiving objects: 100% (2569/2569), 1006.56 KiB | 11.44 MiB/s, done.
Resolving deltas: 100% (3/3), done.
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
remote: Enumerating objects: 2569, done.
remote: Counting objects: 100% (405/405), done.
remote: Compressing objects: 100% (405/405), done.
Receiving objects: 100% (2569/2569), 1006.45 KiB | 21.88 MiB/s, done.
Resolving deltas: 100% (3/3), done.
remote: Total 2569 (delta 3), reused 0 (delta 0), pack-reused 2164 (from 1)
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400  1) # frozen_string_literal: true
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400  2)
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400  3) class UpdateUserOptionsForThreadTitlePrompts < ActiveRecord::Migration[7.0]
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400  4)   def up
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400  5)     change_column_default :user_options, :show_thread_title_prompts, true
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400  6)
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400  7)     if DB.query_single(
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400  8)          "SELECT 1 FROM user_options WHERE show_thread_title_prompts IS NULL LIMIT 1",
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400  9)        ).first
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 10)       batch_size = 100_000
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 11)       min_id = DB.query_single("SELECT MIN(user_id) FROM user_options").first.to_i
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 12)       max_id = DB.query_single("SELECT MAX(user_id) FROM user_options").first.to_i
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 13)       while max_id >= min_id
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 14)         DB.exec(
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 15)           "UPDATE user_options SET show_thread_title_prompts = true WHERE user_id > #{max_id - batch_size} AND user_id <= #{max_id}",
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 16)         )
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 17)         max_id -= batch_size
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 18)       end
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 19)     end
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 20)
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 21)     change_column_null :user_options, :show_thread_title_prompts, false
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 22)   end
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 23)
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 24)   def down
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 25)   end
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 26) end
:...skipping...
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400  1) # frozen_string_literal: true
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400  2)
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400  3) class UpdateUserOptionsForThreadTitlePrompts < ActiveRecord::Migration[7.0]
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400  4)   def up
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400  5)     change_column_default :user_options, :show_thread_title_prompts, true
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400  6)
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400  7)     if DB.query_single(
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400  8)          "SELECT 1 FROM user_options WHERE show_thread_title_prompts IS NULL LIMIT 1",
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400  9)        ).first
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 10)       batch_size = 100_000
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 11)       min_id = DB.query_single("SELECT MIN(user_id) FROM user_options").first.to_i
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 12)       max_id = DB.query_single("SELECT MAX(user_id) FROM user_options").first.to_i
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 13)       while max_id >= min_id
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 14)         DB.exec(
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 15)           "UPDATE user_options SET show_thread_title_prompts = true WHERE user_id > #{max_id - batch_size} AND user_id <= #{max_id}",
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 16)         )
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 17)         max_id -= batch_size
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 18)       end
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 19)     end
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 20)
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 21)     change_column_null :user_options, :show_thread_title_prompts, false
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 22)   end
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 23)
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 24)   def down
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 25)   end
34c4acd32f5 (David Battersby 2024-05-17 00:53:19 +0400 26) end
~