FEATURE: experimental hidden setting for draft backups

Under exceptional situations the automatic draft feature can fail.

This new **hidden, default off** site setting
`backup_drafts_to_pm_length` will automatically backup any draft that is
saved by the system to a dedicated PM (originating from self)

The body of that PM will contain the text of the reply.

We can enable this feature strategically on sites exhibiting issues to
diagnose issues with the draft system and offer a recourse to users who
appear to lose drafts. We automatically checkpoint these drafts every 5
minutes forcing a new revision each 5 minutes so you can revert to old
content.

Longer term we are considering automatically enabling this kind of feature
for extremely long drafts where the risk is really high one could lose
days of writing.
This commit is contained in:
Sam Saffron
2019-10-17 16:56:40 +11:00
parent 4338515a85
commit f5d1aff8dd
8 changed files with 224 additions and 23 deletions

View File

@@ -0,0 +1,25 @@
# frozen_string_literal: true
class AddDraftBackupTables < ActiveRecord::Migration[6.0]
def change
create_table :backup_draft_topics do |t|
t.integer :user_id, null: false
t.integer :topic_id, null: false
t.timestamps
end
create_table :backup_draft_posts do |t|
t.integer :user_id, null: false
t.integer :post_id, null: false
t.string :key, null: false
t.timestamps
end
add_index :backup_draft_posts, [:user_id, :key], unique: true
add_index :backup_draft_posts, [:post_id], unique: true
add_index :backup_draft_topics, [:user_id], unique: true
add_index :backup_draft_topics, [:topic_id], unique: true
end
end