about summary refs log tree commit diff
path: root/db/migrate
diff options
context:
space:
mode:
authorStarfall <us@starfall.systems>2022-04-29 09:20:51 -0500
committerStarfall <us@starfall.systems>2022-04-29 09:20:51 -0500
commit4eb291e5db6114c8aa564f0c9e7f04d13805b5cc (patch)
tree1a6affcf635974ccf6d0f650a3bbe2be75c7929e /db/migrate
parentbcaacc42334d75bd361f330989041a9beba101a9 (diff)
parent252deefe3433d0cedafd973becd0d85b5182eb49 (diff)
Merge remote-tracking branch 'glitch/main'
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20190715164535_add_instance_actor.rb8
-rw-r--r--db/migrate/20220428112511_add_index_statuses_on_account_id.rb7
-rw-r--r--db/migrate/20220428112727_add_index_statuses_pins_on_status_id.rb7
-rw-r--r--db/migrate/20220428114454_add_index_reports_on_assigned_account_id.rb7
-rw-r--r--db/migrate/20220428114902_add_index_reports_on_action_taken_by_account_id.rb7
5 files changed, 36 insertions, 0 deletions
diff --git a/db/migrate/20190715164535_add_instance_actor.rb b/db/migrate/20190715164535_add_instance_actor.rb
index 8c0301d69..0ae53199a 100644
--- a/db/migrate/20190715164535_add_instance_actor.rb
+++ b/db/migrate/20190715164535_add_instance_actor.rb
@@ -2,6 +2,14 @@ class AddInstanceActor < ActiveRecord::Migration[5.2]
   class Account < ApplicationRecord
     # Dummy class, to make migration possible across version changes
     validates :username, uniqueness: { scope: :domain, case_sensitive: false }
+
+    before_create :generate_keys
+
+    def generate_keys
+      keypair = OpenSSL::PKey::RSA.new(2048)
+      self.private_key = keypair.to_pem
+      self.public_key  = keypair.public_key.to_pem
+    end
   end
 
   def up
diff --git a/db/migrate/20220428112511_add_index_statuses_on_account_id.rb b/db/migrate/20220428112511_add_index_statuses_on_account_id.rb
new file mode 100644
index 000000000..87a601b72
--- /dev/null
+++ b/db/migrate/20220428112511_add_index_statuses_on_account_id.rb
@@ -0,0 +1,7 @@
+class AddIndexStatusesOnAccountId < ActiveRecord::Migration[6.1]
+  disable_ddl_transaction!
+
+  def change
+    add_index :statuses, [:account_id], name: :index_statuses_on_account_id, algorithm: :concurrently
+  end
+end
diff --git a/db/migrate/20220428112727_add_index_statuses_pins_on_status_id.rb b/db/migrate/20220428112727_add_index_statuses_pins_on_status_id.rb
new file mode 100644
index 000000000..26a543087
--- /dev/null
+++ b/db/migrate/20220428112727_add_index_statuses_pins_on_status_id.rb
@@ -0,0 +1,7 @@
+class AddIndexStatusesPinsOnStatusId < ActiveRecord::Migration[6.1]
+  disable_ddl_transaction!
+
+  def change
+    add_index :status_pins, [:status_id], name: :index_status_pins_on_status_id, algorithm: :concurrently
+  end
+end
diff --git a/db/migrate/20220428114454_add_index_reports_on_assigned_account_id.rb b/db/migrate/20220428114454_add_index_reports_on_assigned_account_id.rb
new file mode 100644
index 000000000..c260c9732
--- /dev/null
+++ b/db/migrate/20220428114454_add_index_reports_on_assigned_account_id.rb
@@ -0,0 +1,7 @@
+class AddIndexReportsOnAssignedAccountId < ActiveRecord::Migration[6.1]
+  disable_ddl_transaction!
+
+  def change
+    add_index :reports, [:assigned_account_id], name: :index_reports_on_assigned_account_id, algorithm: :concurrently, where: 'assigned_account_id IS NOT NULL'
+  end
+end
diff --git a/db/migrate/20220428114902_add_index_reports_on_action_taken_by_account_id.rb b/db/migrate/20220428114902_add_index_reports_on_action_taken_by_account_id.rb
new file mode 100644
index 000000000..aed88cd80
--- /dev/null
+++ b/db/migrate/20220428114902_add_index_reports_on_action_taken_by_account_id.rb
@@ -0,0 +1,7 @@
+class AddIndexReportsOnActionTakenByAccountId < ActiveRecord::Migration[6.1]
+  disable_ddl_transaction!
+
+  def change
+    add_index :reports, [:action_taken_by_account_id], name: :index_reports_on_action_taken_by_account_id, algorithm: :concurrently, where: 'action_taken_by_account_id IS NOT NULL'
+  end
+end