about summary refs log tree commit diff
path: root/db
diff options
context:
space:
mode:
authorFire Demon <firedemon@creature.cafe>2020-08-20 06:26:19 -0500
committerFire Demon <firedemon@creature.cafe>2020-08-30 05:45:19 -0500
commit6317cb60e03762596ecae034518b4da4c60a8f64 (patch)
treed0ed510079f5373fe8d2cb420d93866ae32201f2 /db
parent4d08871722a9186f0c82c41c6a465982f80c06b2 (diff)
[Federation, Feature] Add support for pull federation, account synchronization, and server-to-server migration
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20200818040629_add_last_synced_at_to_accounts.rb5
-rw-r--r--db/migrate/20200818160057_create_collection_items.rb12
-rw-r--r--db/migrate/20200818160106_create_collection_pages.rb13
-rw-r--r--db/schema.rb26
4 files changed, 55 insertions, 1 deletions
diff --git a/db/migrate/20200818040629_add_last_synced_at_to_accounts.rb b/db/migrate/20200818040629_add_last_synced_at_to_accounts.rb
new file mode 100644
index 000000000..0d64b5109
--- /dev/null
+++ b/db/migrate/20200818040629_add_last_synced_at_to_accounts.rb
@@ -0,0 +1,5 @@
+class AddLastSyncedAtToAccounts < ActiveRecord::Migration[5.2]
+  def change
+    add_column :accounts, :last_synced_at, :datetime
+  end
+end
diff --git a/db/migrate/20200818160057_create_collection_items.rb b/db/migrate/20200818160057_create_collection_items.rb
new file mode 100644
index 000000000..88796ce0e
--- /dev/null
+++ b/db/migrate/20200818160057_create_collection_items.rb
@@ -0,0 +1,12 @@
+class CreateCollectionItems < ActiveRecord::Migration[5.2]
+  def change
+    create_table :collection_items do |t|
+      t.references :account, index: true, foreign_key: { on_delete: :cascade }
+      t.string :uri, null: false, index: { unique: true }
+      t.boolean :processed, null: false, default: false
+    end
+
+    add_index :collection_items, :id, name: 'unprocessed_collection_item_ids', where: 'processed = FALSE', order: { id: :desc }
+    add_index :collection_items, :account_id, name: 'unprocessed_collection_item_account_ids', where: 'processed = FALSE'
+  end
+end
diff --git a/db/migrate/20200818160106_create_collection_pages.rb b/db/migrate/20200818160106_create_collection_pages.rb
new file mode 100644
index 000000000..d00e1ca1c
--- /dev/null
+++ b/db/migrate/20200818160106_create_collection_pages.rb
@@ -0,0 +1,13 @@
+class CreateCollectionPages < ActiveRecord::Migration[5.2]
+  def change
+    create_table :collection_pages do |t|
+      t.references :account, index: true, foreign_key: { on_delete: :cascade }
+      t.string :uri, null: false, index: { unique: true }
+      t.string :next
+    end
+
+    add_index :collection_pages, :id, name: 'unprocessed_collection_page_ids', where: 'next IS NULL'
+    add_index :collection_pages, :account_id, name: 'unprocessed_collection_page_account_ids', where: 'next IS NULL'
+    add_index :collection_pages, :uri, name: 'unprocessed_collection_pages_uris', where: 'next IS NULL'
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 6607f1bf7..267a55316 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_08_17_225525) do
+ActiveRecord::Schema.define(version: 2020_08_18_160106) do
 
   # These are extensions that must be enabled in order to support this database
   enable_extension "plpgsql"
@@ -203,6 +203,7 @@ ActiveRecord::Schema.define(version: 2020_08_17_225525) do
     t.boolean "show_unlisted", default: true, null: false
     t.boolean "private", default: false, null: false
     t.boolean "require_auth", default: false, null: false
+    t.datetime "last_synced_at"
     t.index "(((setweight(to_tsvector('simple'::regconfig, (display_name)::text), 'A'::\"char\") || setweight(to_tsvector('simple'::regconfig, (username)::text), 'B'::\"char\")) || setweight(to_tsvector('simple'::regconfig, (COALESCE(domain, ''::character varying))::text), 'C'::\"char\")))", name: "search_index", using: :gin
     t.index "lower((username)::text), COALESCE(lower((domain)::text), ''::text)", name: "index_accounts_on_username_and_domain_lower", unique: true
     t.index ["moved_to_account_id"], name: "index_accounts_on_moved_to_account_id"
@@ -293,6 +294,27 @@ ActiveRecord::Schema.define(version: 2020_08_17_225525) do
     t.index ["status_id"], name: "index_bookmarks_on_status_id"
   end
 
+  create_table "collection_items", force: :cascade do |t|
+    t.bigint "account_id"
+    t.string "uri", null: false
+    t.boolean "processed", default: false, null: false
+    t.index ["account_id"], name: "index_collection_items_on_account_id"
+    t.index ["account_id"], name: "unprocessed_collection_item_account_ids", where: "(processed = false)"
+    t.index ["id"], name: "unprocessed_collection_item_ids", order: :desc, where: "(processed = false)"
+    t.index ["uri"], name: "index_collection_items_on_uri", unique: true
+  end
+
+  create_table "collection_pages", force: :cascade do |t|
+    t.bigint "account_id"
+    t.string "uri", null: false
+    t.string "next"
+    t.index ["account_id"], name: "index_collection_pages_on_account_id"
+    t.index ["account_id"], name: "unprocessed_collection_page_account_ids", where: "(next IS NULL)"
+    t.index ["id"], name: "unprocessed_collection_page_ids", where: "(next IS NULL)"
+    t.index ["uri"], name: "index_collection_pages_on_uri", unique: true
+    t.index ["uri"], name: "unprocessed_collection_pages_uris", where: "(next IS NULL)"
+  end
+
   create_table "conversation_mutes", force: :cascade do |t|
     t.bigint "conversation_id", null: false
     t.bigint "account_id", null: false
@@ -1037,6 +1059,8 @@ ActiveRecord::Schema.define(version: 2020_08_17_225525) do
   add_foreign_key "blocks", "accounts", name: "fk_4269e03e65", on_delete: :cascade
   add_foreign_key "bookmarks", "accounts", on_delete: :cascade
   add_foreign_key "bookmarks", "statuses", on_delete: :cascade
+  add_foreign_key "collection_items", "accounts", on_delete: :cascade
+  add_foreign_key "collection_pages", "accounts", on_delete: :cascade
   add_foreign_key "conversation_mutes", "accounts", name: "fk_225b4212bb", on_delete: :cascade
   add_foreign_key "conversation_mutes", "conversations", on_delete: :cascade
   add_foreign_key "conversations", "accounts"