about summary refs log tree commit diff
path: root/db
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-05-18 12:58:54 -0500
committermultiple creatures <dev@multiple-creature.party>2019-05-21 03:16:50 -0500
commit09b7532805a349d1a57f4a650c7f41456cda184b (patch)
tree74b52c2b91609cbf94c8442fb701dfb8e922ce36 /db
parent5c9aed40f6c046629b548df402ca2f13ba36efe0 (diff)
split `i:am` signatures into their very own `footer` column
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20190518044851_add_footer_to_statuses.rb5
-rw-r--r--db/migrate/20190518150215_reformat_local_statuses.rb19
-rw-r--r--db/schema.rb3
3 files changed, 26 insertions, 1 deletions
diff --git a/db/migrate/20190518044851_add_footer_to_statuses.rb b/db/migrate/20190518044851_add_footer_to_statuses.rb
new file mode 100644
index 000000000..e85d225bc
--- /dev/null
+++ b/db/migrate/20190518044851_add_footer_to_statuses.rb
@@ -0,0 +1,5 @@
+class AddFooterToStatuses < ActiveRecord::Migration[5.2]
+  def change
+    add_column :statuses, :footer, :text
+  end
+end
diff --git a/db/migrate/20190518150215_reformat_local_statuses.rb b/db/migrate/20190518150215_reformat_local_statuses.rb
new file mode 100644
index 000000000..c9433a044
--- /dev/null
+++ b/db/migrate/20190518150215_reformat_local_statuses.rb
@@ -0,0 +1,19 @@
+class ReformatLocalStatuses < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+  def up
+    Status.local.without_reblogs.find_each do |status|
+      status.content_type = 'text/x-bbcode+markdown'
+      text = status.text
+      matches = text.match(/\[(right|rfloat)\][\u200c\u200b—–-]+ *(.*?)\[\/\1\]\u200c?\Z/)
+      if matches
+        status.footer = matches[2].strip
+        text = text.sub(/\[(right|rfloat)\][\u200c\u200b—–-]+.*?\[\/\1\]\u200c?\Z/, '').rstrip
+      end
+      text = text.gsub(/\[(color|colorhex|hexcolor)=\w+\](.*?)\[\/\1\]/, '[b]\2[/b]')
+      text = text.gsub(/\[(spin|pulse)\](.*?)\[\/\1\]/, '[b]\2[/b]')
+      status.text = text unless text.blank?
+      Rails.logger.info("Rewrote status ID #{status.id}")
+      status.save
+    end
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 46edcab6a..cc71d3fce 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -644,11 +644,12 @@ ActiveRecord::Schema.define(version: 2019_05_19_130537) do
     t.bigint "in_reply_to_account_id"
     t.boolean "local_only"
     t.bigint "poll_id"
-    t.string "content_type"
     t.tsvector "tsv"
     t.boolean "curated", default: false, null: false
     t.string "sharekey"
     t.boolean "network", default: false, null: false
+    t.string "content_type"
+    t.text "footer"
     t.index ["account_id", "id", "visibility", "updated_at"], name: "index_statuses_20180106", order: { id: :desc }
     t.index ["in_reply_to_account_id"], name: "index_statuses_on_in_reply_to_account_id"
     t.index ["in_reply_to_id"], name: "index_statuses_on_in_reply_to_id"