From 30dcefb14a993633f1994892c8d886d23435e962 Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Wed, 9 Apr 2025 17:15:42 +0200 Subject: [PATCH] Migration to migrate URLs after renaming bubbles => cards --- script/migrate_to_new_cards_url_scheme.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 script/migrate_to_new_cards_url_scheme.rb diff --git a/script/migrate_to_new_cards_url_scheme.rb b/script/migrate_to_new_cards_url_scheme.rb new file mode 100755 index 000000000..f5053dac1 --- /dev/null +++ b/script/migrate_to_new_cards_url_scheme.rb @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +require_relative "../config/environment" + +def replace_url(string) + string.gsub(%r{/buckets/(\d+)/bubbles/(\d+)}) do + "/collections/#{$1}/cards/#{$2}" + end +end + +ApplicationRecord.with_each_tenant do |tenant| + Account.find_each do |account| + Comment.find_each do |comment| + comment.update!(body: replace_url(comment.body.content.to_s)) + end + end +end