about summary refs log tree commit diff
path: root/db
diff options
context:
space:
mode:
authorDarius Kazemi <darius.kazemi@gmail.com>2019-04-30 15:29:28 -0700
committerFire Demon <firedemon@creature.cafe>2020-08-30 05:45:15 -0500
commit6378feffa8935238bdb5f1f1c01fcb102440fe30 (patch)
treeb1eea210ace7eb72a00ab4604c3ec10c5ae4db4b /db
parent4eb49257fc618219709b357fb68f4d6156cab249 (diff)
[Feature, Federation, Port: hometown@b3e6597] Support locally cached inline images [+ Monsterfork additions]
Changes added by Monsterfork:
- Do not limit to only Articles
- Reuse existing media; retroactively using more-detailed descriptions
- Also scrub carrige returns between tags
- Handle download failures
- Attach to statuses and keep track of inlined media
- Handle local edits

Co-authored-by: Fire Demon <firedemon@creature.cafe>
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20200724035808_add_inline_to_media_attachments.rb7
-rw-r--r--db/migrate/20200724045955_create_inline_media_attachments.rb12
-rw-r--r--db/schema.rb13
3 files changed, 31 insertions, 1 deletions
diff --git a/db/migrate/20200724035808_add_inline_to_media_attachments.rb b/db/migrate/20200724035808_add_inline_to_media_attachments.rb
new file mode 100644
index 000000000..171eca4b5
--- /dev/null
+++ b/db/migrate/20200724035808_add_inline_to_media_attachments.rb
@@ -0,0 +1,7 @@
+class AddInlineToMediaAttachments < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      add_column :media_attachments, :inline, :boolean, default: false, null: false
+    end
+  end
+end
diff --git a/db/migrate/20200724045955_create_inline_media_attachments.rb b/db/migrate/20200724045955_create_inline_media_attachments.rb
new file mode 100644
index 000000000..a894c3868
--- /dev/null
+++ b/db/migrate/20200724045955_create_inline_media_attachments.rb
@@ -0,0 +1,12 @@
+class CreateInlineMediaAttachments < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def change
+    create_table :inline_media_attachments do |t|
+      t.references :status, index: { algorithm: :concurrently }, foreign_key: { on_delete: :cascade }
+      t.references :media_attachment, index: { algorithm: :concurrently }, foreign_key: { on_delete: :cascade }
+    end
+
+    add_index :inline_media_attachments, [:status_id, :media_attachment_id], unique: true, algorithm: :concurrently, name: 'uniq_index_on_status_and_attachment'
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 901c13c76..3cbbd7732 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
 #
 # It's strongly recommended that you check this file into your version control system.
 
-ActiveRecord::Schema.define(version: 2020_07_21_221659) do
+ActiveRecord::Schema.define(version: 2020_07_24_045955) do
 
   # These are extensions that must be enabled in order to support this database
   enable_extension "plpgsql"
@@ -448,6 +448,14 @@ ActiveRecord::Schema.define(version: 2020_07_21_221659) do
     t.boolean "overwrite", default: false, null: false
   end
 
+  create_table "inline_media_attachments", force: :cascade do |t|
+    t.bigint "status_id"
+    t.bigint "media_attachment_id"
+    t.index ["media_attachment_id"], name: "index_inline_media_attachments_on_media_attachment_id"
+    t.index ["status_id", "media_attachment_id"], name: "uniq_index_on_status_and_attachment", unique: true
+    t.index ["status_id"], name: "index_inline_media_attachments_on_status_id"
+  end
+
   create_table "invites", force: :cascade do |t|
     t.bigint "user_id", null: false
     t.string "code", default: "", null: false
@@ -513,6 +521,7 @@ ActiveRecord::Schema.define(version: 2020_07_21_221659) do
     t.integer "thumbnail_file_size"
     t.datetime "thumbnail_updated_at"
     t.string "thumbnail_remote_url"
+    t.boolean "inline", default: false, null: false
     t.index ["account_id"], name: "index_media_attachments_on_account_id"
     t.index ["scheduled_status_id"], name: "index_media_attachments_on_scheduled_status_id"
     t.index ["shortcode"], name: "index_media_attachments_on_shortcode", unique: true
@@ -984,6 +993,8 @@ ActiveRecord::Schema.define(version: 2020_07_21_221659) do
   add_foreign_key "follows", "accounts", name: "fk_32ed1b5560", on_delete: :cascade
   add_foreign_key "identities", "users", name: "fk_bea040f377", on_delete: :cascade
   add_foreign_key "imports", "accounts", name: "fk_6db1b6e408", on_delete: :cascade
+  add_foreign_key "inline_media_attachments", "media_attachments", on_delete: :cascade
+  add_foreign_key "inline_media_attachments", "statuses", on_delete: :cascade
   add_foreign_key "invites", "users", on_delete: :cascade
   add_foreign_key "list_accounts", "accounts", on_delete: :cascade
   add_foreign_key "list_accounts", "follows", on_delete: :cascade