about summary refs log tree commit diff
path: root/db
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2020-06-09 10:39:20 +0200
committerThibaut Girka <thib@sitedethib.com>2020-06-09 10:39:20 +0200
commit12c8ac9e1443d352eca3538ed1558de8ccdd9434 (patch)
treeed480d77b29f0d571ad219190288bde3b0c09b32 /db
parentf328f2faa3fbdb182921366c6a20e745c069b840 (diff)
parent89f40b6c3ec525b09d02f21e9b45276084167d8d (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
- `app/controllers/activitypub/collections_controller.rb`:
  Conflict due to glitch-soc having to take care of local-only
  pinned toots in that controller.
  Took upstream's changes and restored the local-only special
  handling.
- `app/controllers/auth/sessions_controller.rb`:
  Minor conflicts due to the theming system, applied upstream
  changes, adapted the following two files for glitch-soc's
  theming system:
  - `app/controllers/concerns/sign_in_token_authentication_concern.rb`
  - `app/controllers/concerns/two_factor_authentication_concern.rb`
- `app/services/backup_service.rb`:
  Minor conflict due to glitch-soc having to handle local-only
  toots specially. Applied upstream changes and restored
  the local-only special handling.
- `app/views/admin/custom_emojis/index.html.haml`:
  Minor conflict due to the theming system.
- `package.json`:
  Upstream dependency updated, too close to a glitch-soc-only
  dependency in the file.
- `yarn.lock`:
  Upstream dependency updated, too close to a glitch-soc-only
  dependency in the file.
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20170129000348_create_devices.rb13
-rw-r--r--db/migrate/20170205175257_remove_devices.rb2
-rw-r--r--db/migrate/20200516180352_create_devices.rb14
-rw-r--r--db/migrate/20200516183822_create_one_time_keys.rb12
-rw-r--r--db/migrate/20200518083523_create_encrypted_messages.rb15
-rw-r--r--db/migrate/20200521180606_encrypted_message_ids_to_timestamp_ids.rb13
-rw-r--r--db/migrate/20200529214050_add_devices_url_to_accounts.rb5
-rw-r--r--db/migrate/20200601222558_create_system_keys.rb9
-rw-r--r--db/migrate/20200605155027_add_blurhash_to_preview_cards.rb5
-rw-r--r--db/migrate/20200608113046_add_sign_in_token_to_users.rb6
-rw-r--r--db/schema.rb55
11 files changed, 134 insertions, 15 deletions
diff --git a/db/migrate/20170129000348_create_devices.rb b/db/migrate/20170129000348_create_devices.rb
deleted file mode 100644
index bf8f5fc6e..000000000
--- a/db/migrate/20170129000348_create_devices.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-class CreateDevices < ActiveRecord::Migration[5.0]
-  def change
-    create_table :devices do |t|
-      t.integer :account_id, null: false
-      t.string :registration_id, null: false, default: ''
-
-      t.timestamps
-    end
-
-    add_index :devices, :registration_id
-    add_index :devices, :account_id
-  end
-end
diff --git a/db/migrate/20170205175257_remove_devices.rb b/db/migrate/20170205175257_remove_devices.rb
index e96ffed4d..9ef5c440e 100644
--- a/db/migrate/20170205175257_remove_devices.rb
+++ b/db/migrate/20170205175257_remove_devices.rb
@@ -1,5 +1,5 @@
 class RemoveDevices < ActiveRecord::Migration[5.0]
   def change
-    drop_table :devices
+    drop_table :devices if table_exists?(:devices)
   end
 end
diff --git a/db/migrate/20200516180352_create_devices.rb b/db/migrate/20200516180352_create_devices.rb
new file mode 100644
index 000000000..04a628a89
--- /dev/null
+++ b/db/migrate/20200516180352_create_devices.rb
@@ -0,0 +1,14 @@
+class CreateDevices < ActiveRecord::Migration[5.2]
+  def change
+    create_table :devices do |t|
+      t.references :access_token, foreign_key: { to_table: :oauth_access_tokens, on_delete: :cascade, index: :unique }
+      t.references :account, foreign_key: { on_delete: :cascade }
+      t.string :device_id, default: '', null: false
+      t.string :name, default: '', null: false
+      t.text :fingerprint_key, default: '', null: false
+      t.text :identity_key, default: '', null: false
+
+      t.timestamps
+    end
+  end
+end
diff --git a/db/migrate/20200516183822_create_one_time_keys.rb b/db/migrate/20200516183822_create_one_time_keys.rb
new file mode 100644
index 000000000..642b9e632
--- /dev/null
+++ b/db/migrate/20200516183822_create_one_time_keys.rb
@@ -0,0 +1,12 @@
+class CreateOneTimeKeys < ActiveRecord::Migration[5.2]
+  def change
+    create_table :one_time_keys do |t|
+      t.references :device, foreign_key: { on_delete: :cascade }
+      t.string :key_id, default: '', null: false, index: :unique
+      t.text :key, default: '', null: false
+      t.text :signature, default: '', null: false
+
+      t.timestamps
+    end
+  end
+end
diff --git a/db/migrate/20200518083523_create_encrypted_messages.rb b/db/migrate/20200518083523_create_encrypted_messages.rb
new file mode 100644
index 000000000..486726303
--- /dev/null
+++ b/db/migrate/20200518083523_create_encrypted_messages.rb
@@ -0,0 +1,15 @@
+class CreateEncryptedMessages < ActiveRecord::Migration[5.2]
+  def change
+    create_table :encrypted_messages do |t|
+      t.references :device, foreign_key: { on_delete: :cascade }
+      t.references :from_account, foreign_key: { to_table: :accounts, on_delete: :cascade }
+      t.string :from_device_id, default: '', null: false
+      t.integer :type, default: 0, null: false
+      t.text :body, default: '', null: false
+      t.text :digest, default: '', null: false
+      t.text :message_franking, default: '', null: false
+
+      t.timestamps
+    end
+  end
+end
diff --git a/db/migrate/20200521180606_encrypted_message_ids_to_timestamp_ids.rb b/db/migrate/20200521180606_encrypted_message_ids_to_timestamp_ids.rb
new file mode 100644
index 000000000..24d43a0bf
--- /dev/null
+++ b/db/migrate/20200521180606_encrypted_message_ids_to_timestamp_ids.rb
@@ -0,0 +1,13 @@
+class EncryptedMessageIdsToTimestampIds < ActiveRecord::Migration[5.2]
+  def up
+    safety_assured do
+      execute("ALTER TABLE encrypted_messages ALTER COLUMN id SET DEFAULT timestamp_id('encrypted_messages')")
+    end
+  end
+
+  def down
+    execute("LOCK encrypted_messages")
+    execute("SELECT setval('encrypted_messages_id_seq', (SELECT MAX(id) FROM encrypted_messages))")
+    execute("ALTER TABLE encrypted_messages ALTER COLUMN id SET DEFAULT nextval('encrypted_messages_id_seq')")
+  end
+end
diff --git a/db/migrate/20200529214050_add_devices_url_to_accounts.rb b/db/migrate/20200529214050_add_devices_url_to_accounts.rb
new file mode 100644
index 000000000..564877e5d
--- /dev/null
+++ b/db/migrate/20200529214050_add_devices_url_to_accounts.rb
@@ -0,0 +1,5 @@
+class AddDevicesUrlToAccounts < ActiveRecord::Migration[5.2]
+  def change
+    add_column :accounts, :devices_url, :string
+  end
+end
diff --git a/db/migrate/20200601222558_create_system_keys.rb b/db/migrate/20200601222558_create_system_keys.rb
new file mode 100644
index 000000000..fd9d221aa
--- /dev/null
+++ b/db/migrate/20200601222558_create_system_keys.rb
@@ -0,0 +1,9 @@
+class CreateSystemKeys < ActiveRecord::Migration[5.2]
+  def change
+    create_table :system_keys do |t|
+      t.binary :key
+
+      t.timestamps
+    end
+  end
+end
diff --git a/db/migrate/20200605155027_add_blurhash_to_preview_cards.rb b/db/migrate/20200605155027_add_blurhash_to_preview_cards.rb
new file mode 100644
index 000000000..dc4b7a984
--- /dev/null
+++ b/db/migrate/20200605155027_add_blurhash_to_preview_cards.rb
@@ -0,0 +1,5 @@
+class AddBlurhashToPreviewCards < ActiveRecord::Migration[5.2]
+  def change
+    add_column :preview_cards, :blurhash, :string
+  end
+end
diff --git a/db/migrate/20200608113046_add_sign_in_token_to_users.rb b/db/migrate/20200608113046_add_sign_in_token_to_users.rb
new file mode 100644
index 000000000..baa63c10f
--- /dev/null
+++ b/db/migrate/20200608113046_add_sign_in_token_to_users.rb
@@ -0,0 +1,6 @@
+class AddSignInTokenToUsers < ActiveRecord::Migration[5.2]
+  def change
+    add_column :users, :sign_in_token, :string
+    add_column :users, :sign_in_token_sent_at, :datetime
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index e52fefa91..c1b6ffa81 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_05_10_110808) do
+ActiveRecord::Schema.define(version: 2020_06_08_113046) do
 
   # These are extensions that must be enabled in order to support this database
   enable_extension "plpgsql"
@@ -174,6 +174,7 @@ ActiveRecord::Schema.define(version: 2020_05_10_110808) do
     t.boolean "hide_collections"
     t.integer "avatar_storage_schema_version"
     t.integer "header_storage_schema_version"
+    t.string "devices_url"
     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), lower((domain)::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"
@@ -317,6 +318,19 @@ ActiveRecord::Schema.define(version: 2020_05_10_110808) do
     t.index ["account_id"], name: "index_custom_filters_on_account_id"
   end
 
+  create_table "devices", force: :cascade do |t|
+    t.bigint "access_token_id"
+    t.bigint "account_id"
+    t.string "device_id", default: "", null: false
+    t.string "name", default: "", null: false
+    t.text "fingerprint_key", default: "", null: false
+    t.text "identity_key", default: "", null: false
+    t.datetime "created_at", null: false
+    t.datetime "updated_at", null: false
+    t.index ["access_token_id"], name: "index_devices_on_access_token_id"
+    t.index ["account_id"], name: "index_devices_on_account_id"
+  end
+
   create_table "domain_allows", force: :cascade do |t|
     t.string "domain", default: "", null: false
     t.datetime "created_at", null: false
@@ -344,6 +358,20 @@ ActiveRecord::Schema.define(version: 2020_05_10_110808) do
     t.index ["domain"], name: "index_email_domain_blocks_on_domain", unique: true
   end
 
+  create_table "encrypted_messages", id: :bigint, default: -> { "timestamp_id('encrypted_messages'::text)" }, force: :cascade do |t|
+    t.bigint "device_id"
+    t.bigint "from_account_id"
+    t.string "from_device_id", default: "", null: false
+    t.integer "type", default: 0, null: false
+    t.text "body", default: "", null: false
+    t.text "digest", default: "", null: false
+    t.text "message_franking", default: "", null: false
+    t.datetime "created_at", null: false
+    t.datetime "updated_at", null: false
+    t.index ["device_id"], name: "index_encrypted_messages_on_device_id"
+    t.index ["from_account_id"], name: "index_encrypted_messages_on_from_account_id"
+  end
+
   create_table "favourites", force: :cascade do |t|
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
@@ -552,6 +580,17 @@ ActiveRecord::Schema.define(version: 2020_05_10_110808) do
     t.index ["uid"], name: "index_oauth_applications_on_uid", unique: true
   end
 
+  create_table "one_time_keys", force: :cascade do |t|
+    t.bigint "device_id"
+    t.string "key_id", default: "", null: false
+    t.text "key", default: "", null: false
+    t.text "signature", default: "", null: false
+    t.datetime "created_at", null: false
+    t.datetime "updated_at", null: false
+    t.index ["device_id"], name: "index_one_time_keys_on_device_id"
+    t.index ["key_id"], name: "index_one_time_keys_on_key_id"
+  end
+
   create_table "pghero_space_stats", force: :cascade do |t|
     t.text "database"
     t.text "schema"
@@ -610,6 +649,7 @@ ActiveRecord::Schema.define(version: 2020_05_10_110808) do
     t.datetime "updated_at", null: false
     t.string "embed_url", default: "", null: false
     t.integer "image_storage_schema_version"
+    t.string "blurhash"
     t.index ["url"], name: "index_preview_cards_on_url", unique: true
   end
 
@@ -752,6 +792,12 @@ ActiveRecord::Schema.define(version: 2020_05_10_110808) do
     t.index ["tag_id", "status_id"], name: "index_statuses_tags_on_tag_id_and_status_id", unique: true
   end
 
+  create_table "system_keys", force: :cascade do |t|
+    t.binary "key"
+    t.datetime "created_at", null: false
+    t.datetime "updated_at", null: false
+  end
+
   create_table "tags", force: :cascade do |t|
     t.string "name", default: "", null: false
     t.datetime "created_at", null: false
@@ -827,6 +873,8 @@ ActiveRecord::Schema.define(version: 2020_05_10_110808) do
     t.string "chosen_languages", array: true
     t.bigint "created_by_application_id"
     t.boolean "approved", default: true, null: false
+    t.string "sign_in_token"
+    t.datetime "sign_in_token_sent_at"
     t.index ["account_id"], name: "index_users_on_account_id"
     t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
     t.index ["created_by_application_id"], name: "index_users_on_created_by_application_id"
@@ -886,7 +934,11 @@ ActiveRecord::Schema.define(version: 2020_05_10_110808) do
   add_foreign_key "conversation_mutes", "accounts", name: "fk_225b4212bb", on_delete: :cascade
   add_foreign_key "conversation_mutes", "conversations", on_delete: :cascade
   add_foreign_key "custom_filters", "accounts", on_delete: :cascade
+  add_foreign_key "devices", "accounts", on_delete: :cascade
+  add_foreign_key "devices", "oauth_access_tokens", column: "access_token_id", on_delete: :cascade
   add_foreign_key "email_domain_blocks", "email_domain_blocks", column: "parent_id", on_delete: :cascade
+  add_foreign_key "encrypted_messages", "accounts", column: "from_account_id", on_delete: :cascade
+  add_foreign_key "encrypted_messages", "devices", on_delete: :cascade
   add_foreign_key "favourites", "accounts", name: "fk_5eb6c2b873", on_delete: :cascade
   add_foreign_key "favourites", "statuses", name: "fk_b0e856845e", on_delete: :cascade
   add_foreign_key "featured_tags", "accounts", on_delete: :cascade
@@ -917,6 +969,7 @@ ActiveRecord::Schema.define(version: 2020_05_10_110808) do
   add_foreign_key "oauth_access_tokens", "oauth_applications", column: "application_id", name: "fk_f5fc4c1ee3", on_delete: :cascade
   add_foreign_key "oauth_access_tokens", "users", column: "resource_owner_id", name: "fk_e84df68546", on_delete: :cascade
   add_foreign_key "oauth_applications", "users", column: "owner_id", name: "fk_b0988c7c0a", on_delete: :cascade
+  add_foreign_key "one_time_keys", "devices", on_delete: :cascade
   add_foreign_key "poll_votes", "accounts", on_delete: :cascade
   add_foreign_key "poll_votes", "polls", on_delete: :cascade
   add_foreign_key "polls", "accounts", on_delete: :cascade