Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorJonne Haß <me@jhass.eu>2020-01-14 13:59:56 +0300
committerJonne Haß <me@jhass.eu>2020-01-22 01:35:01 +0300
commit39c863ead969bbd5c82382cf3ccb95c8d01f8d17 (patch)
tree30f2dc55e69bbe20a7acd060cd0a0e98bc641163 /db
parent6b8cd5d3907ec65192245ffa51dad0e08eee465f (diff)
parent1cbb3f9a7c1696b6088373cbf9e48f40390a5f4e (diff)
Merge branch 'develop' into api
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20171229175654_add_devise_two_factor_to_users.rb13
-rw-r--r--db/migrate/20180302105225_add_two_factor_backupable_to_user.rb7
-rw-r--r--db/migrate/20190509125709_fix_missing_remote_photo_fields.rb11
-rw-r--r--db/migrate/20190511150503_decrypt_two_factor_secret.rb52
-rw-r--r--db/migrate/20190701234716_photos_remove_comment_count.rb14
-rw-r--r--db/migrate/20190703231700_fix_pending_profile_photos.rb9
-rw-r--r--db/migrate/20191018014242_remove_chat.rb10
7 files changed, 116 insertions, 0 deletions
diff --git a/db/migrate/20171229175654_add_devise_two_factor_to_users.rb b/db/migrate/20171229175654_add_devise_two_factor_to_users.rb
new file mode 100644
index 000000000..47280dd20
--- /dev/null
+++ b/db/migrate/20171229175654_add_devise_two_factor_to_users.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddDeviseTwoFactorToUsers < ActiveRecord::Migration[5.1]
+ def change
+ change_table :users, bulk: true do |t|
+ t.string :encrypted_otp_secret
+ t.string :encrypted_otp_secret_iv
+ t.string :encrypted_otp_secret_salt
+ t.integer :consumed_timestep
+ t.boolean :otp_required_for_login
+ end
+ end
+end
diff --git a/db/migrate/20180302105225_add_two_factor_backupable_to_user.rb b/db/migrate/20180302105225_add_two_factor_backupable_to_user.rb
new file mode 100644
index 000000000..f9b6c0b5e
--- /dev/null
+++ b/db/migrate/20180302105225_add_two_factor_backupable_to_user.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddTwoFactorBackupableToUser < ActiveRecord::Migration[5.1]
+ def change
+ add_column :users, :otp_backup_codes, :text
+ end
+end
diff --git a/db/migrate/20190509125709_fix_missing_remote_photo_fields.rb b/db/migrate/20190509125709_fix_missing_remote_photo_fields.rb
new file mode 100644
index 000000000..8d6462643
--- /dev/null
+++ b/db/migrate/20190509125709_fix_missing_remote_photo_fields.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class FixMissingRemotePhotoFields < ActiveRecord::Migration[5.1]
+ def up
+ Photo.where(remote_photo_path: nil).each do |photo|
+ photo.write_attribute(:unprocessed_image, photo.read_attribute(:processed_image))
+ photo.update_remote_path
+ photo.save!
+ end
+ end
+end
diff --git a/db/migrate/20190511150503_decrypt_two_factor_secret.rb b/db/migrate/20190511150503_decrypt_two_factor_secret.rb
new file mode 100644
index 000000000..b1d21f5f6
--- /dev/null
+++ b/db/migrate/20190511150503_decrypt_two_factor_secret.rb
@@ -0,0 +1,52 @@
+# frozen_string_literal: true
+
+class DecryptTwoFactorSecret < ActiveRecord::Migration[5.1]
+ class User < ApplicationRecord
+ end
+
+ def up
+ add_column :users, :plain_otp_secret, :string
+
+ key = twofa_encryption_key
+ decrypt_existing_secrets(key) if key
+
+ change_table :users, bulk: true do |t|
+ t.remove :encrypted_otp_secret
+ t.remove :encrypted_otp_secret_iv
+ t.remove :encrypted_otp_secret_salt
+ end
+ end
+
+ def down
+ raise ActiveRecord::IrreversibleMigration
+ end
+
+ private
+
+ def twofa_encryption_key
+ if AppConfig.heroku?
+ ENV["TWOFA_ENCRYPTION_KEY"]
+ else
+ key_file = File.expand_path("../../config/initializers/twofa_encryption_key.rb", File.dirname(__FILE__))
+
+ if File.exist? key_file
+ require key_file
+ File.delete(key_file)
+
+ return Diaspora::Application.config.twofa_encryption_key
+ end
+ end
+ end
+
+ def decrypt_existing_secrets(key)
+ User.where.not(encrypted_otp_secret: nil).each do |user|
+ user.plain_otp_secret = Encryptor.decrypt(
+ value: user.encrypted_otp_secret.unpack("m").first,
+ key: key,
+ iv: user.encrypted_otp_secret_iv.unpack("m").first,
+ salt: user.encrypted_otp_secret_salt.slice(1..-1).unpack("m").first
+ )
+ user.save!
+ end
+ end
+end
diff --git a/db/migrate/20190701234716_photos_remove_comment_count.rb b/db/migrate/20190701234716_photos_remove_comment_count.rb
new file mode 100644
index 000000000..4d6330960
--- /dev/null
+++ b/db/migrate/20190701234716_photos_remove_comment_count.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class PhotosRemoveCommentCount < ActiveRecord::Migration[5.1]
+ class Comment < ApplicationRecord
+ end
+
+ def change
+ remove_column :photos, :comments_count, :integer
+
+ reversible do |change|
+ change.up { Comment.where(commentable_type: "Photo").delete_all }
+ end
+ end
+end
diff --git a/db/migrate/20190703231700_fix_pending_profile_photos.rb b/db/migrate/20190703231700_fix_pending_profile_photos.rb
new file mode 100644
index 000000000..51b3a1512
--- /dev/null
+++ b/db/migrate/20190703231700_fix_pending_profile_photos.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class FixPendingProfilePhotos < ActiveRecord::Migration[5.1]
+ def up
+ Photo.where(pending: true).each do |photo|
+ photo.update(pending: false) if Profile.where(image_url: photo.url(:thumb_large)).exists?
+ end
+ end
+end
diff --git a/db/migrate/20191018014242_remove_chat.rb b/db/migrate/20191018014242_remove_chat.rb
new file mode 100644
index 000000000..f6f1b3d9d
--- /dev/null
+++ b/db/migrate/20191018014242_remove_chat.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class RemoveChat < ActiveRecord::Migration[5.1]
+ def up
+ remove_column :aspects, :chat_enabled
+ drop_table :chat_contacts
+ drop_table :chat_fragments
+ drop_table :chat_offline_messages
+ end
+end