about summary refs log tree commit diff
path: root/db/migrate
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20171028221157_add_reblogs_to_follows.rb4
-rw-r--r--db/migrate/20171118012443_add_moved_to_account_id_to_accounts.rb6
-rw-r--r--db/migrate/20171119172437_create_admin_action_logs.rb12
-rw-r--r--db/migrate/20171122120436_add_index_account_and_reblog_of_id_to_statuses.rb12
-rw-r--r--db/migrate/20171125024930_create_invites.rb15
-rw-r--r--db/migrate/20171125031751_add_invite_id_to_users.rb5
-rw-r--r--db/migrate/20171125185353_add_index_reblog_of_id_and_account_to_statuses.rb7
-rw-r--r--db/migrate/20171125190735_remove_old_reblog_index_on_statuses.rb14
-rw-r--r--db/migrate/20171129172043_add_index_on_stream_entries.rb7
9 files changed, 79 insertions, 3 deletions
diff --git a/db/migrate/20171028221157_add_reblogs_to_follows.rb b/db/migrate/20171028221157_add_reblogs_to_follows.rb
index eb4640a20..4b5d5b7ff 100644
--- a/db/migrate/20171028221157_add_reblogs_to_follows.rb
+++ b/db/migrate/20171028221157_add_reblogs_to_follows.rb
@@ -3,9 +3,7 @@ require Rails.root.join('lib', 'mastodon', 'migration_helpers')
 class AddReblogsToFollows < ActiveRecord::Migration[5.1]
   include Mastodon::MigrationHelpers
 
-  safety_assured do
-    disable_ddl_transaction!
-  end
+  disable_ddl_transaction!
 
   def up
     safety_assured do
diff --git a/db/migrate/20171118012443_add_moved_to_account_id_to_accounts.rb b/db/migrate/20171118012443_add_moved_to_account_id_to_accounts.rb
new file mode 100644
index 000000000..0c8a894cc
--- /dev/null
+++ b/db/migrate/20171118012443_add_moved_to_account_id_to_accounts.rb
@@ -0,0 +1,6 @@
+class AddMovedToAccountIdToAccounts < ActiveRecord::Migration[5.1]
+  def change
+    add_column :accounts, :moved_to_account_id, :bigint, null: true, default: nil
+    add_foreign_key :accounts, :accounts, column: :moved_to_account_id, on_delete: :nullify
+  end
+end
diff --git a/db/migrate/20171119172437_create_admin_action_logs.rb b/db/migrate/20171119172437_create_admin_action_logs.rb
new file mode 100644
index 000000000..0c2b6c623
--- /dev/null
+++ b/db/migrate/20171119172437_create_admin_action_logs.rb
@@ -0,0 +1,12 @@
+class CreateAdminActionLogs < ActiveRecord::Migration[5.1]
+  def change
+    create_table :admin_action_logs do |t|
+      t.belongs_to :account, foreign_key: { on_delete: :cascade }
+      t.string :action, null: false, default: ''
+      t.references :target, polymorphic: true
+      t.text :recorded_changes, null: false, default: ''
+
+      t.timestamps
+    end
+  end
+end
diff --git a/db/migrate/20171122120436_add_index_account_and_reblog_of_id_to_statuses.rb b/db/migrate/20171122120436_add_index_account_and_reblog_of_id_to_statuses.rb
new file mode 100644
index 000000000..131e54b72
--- /dev/null
+++ b/db/migrate/20171122120436_add_index_account_and_reblog_of_id_to_statuses.rb
@@ -0,0 +1,12 @@
+class AddIndexAccountAndReblogOfIdToStatuses < ActiveRecord::Migration[5.1]
+  disable_ddl_transaction!
+
+  def up
+    # This index has been superseded by migration 20171125185353
+    # add_index :statuses, [:account_id, :reblog_of_id], algorithm: :concurrently
+  end
+
+  def down
+    remove_index :statuses, [:account_id, :reblog_of_id] if index_exists?(:statuses, [:account_id, :reblog_of_id])
+  end
+end
diff --git a/db/migrate/20171125024930_create_invites.rb b/db/migrate/20171125024930_create_invites.rb
new file mode 100644
index 000000000..bcf03bd72
--- /dev/null
+++ b/db/migrate/20171125024930_create_invites.rb
@@ -0,0 +1,15 @@
+class CreateInvites < ActiveRecord::Migration[5.1]
+  def change
+    create_table :invites do |t|
+      t.belongs_to :user, foreign_key: { on_delete: :cascade }
+      t.string :code, null: false, default: ''
+      t.datetime :expires_at, null: true, default: nil
+      t.integer :max_uses, null: true, default: nil
+      t.integer :uses, null: false, default: 0
+
+      t.timestamps
+    end
+
+    add_index :invites, :code, unique: true
+  end
+end
diff --git a/db/migrate/20171125031751_add_invite_id_to_users.rb b/db/migrate/20171125031751_add_invite_id_to_users.rb
new file mode 100644
index 000000000..16829f866
--- /dev/null
+++ b/db/migrate/20171125031751_add_invite_id_to_users.rb
@@ -0,0 +1,5 @@
+class AddInviteIdToUsers < ActiveRecord::Migration[5.1]
+  def change
+    add_reference :users, :invite, null: true, default: nil, foreign_key: { on_delete: :nullify }, index: false
+  end
+end
diff --git a/db/migrate/20171125185353_add_index_reblog_of_id_and_account_to_statuses.rb b/db/migrate/20171125185353_add_index_reblog_of_id_and_account_to_statuses.rb
new file mode 100644
index 000000000..37662eaa5
--- /dev/null
+++ b/db/migrate/20171125185353_add_index_reblog_of_id_and_account_to_statuses.rb
@@ -0,0 +1,7 @@
+class AddIndexReblogOfIdAndAccountToStatuses < ActiveRecord::Migration[5.1]
+  disable_ddl_transaction!
+
+  def change
+    add_index :statuses, [:reblog_of_id, :account_id], algorithm: :concurrently
+  end
+end
diff --git a/db/migrate/20171125190735_remove_old_reblog_index_on_statuses.rb b/db/migrate/20171125190735_remove_old_reblog_index_on_statuses.rb
new file mode 100644
index 000000000..68146c5ce
--- /dev/null
+++ b/db/migrate/20171125190735_remove_old_reblog_index_on_statuses.rb
@@ -0,0 +1,14 @@
+class RemoveOldReblogIndexOnStatuses < ActiveRecord::Migration[5.1]
+  disable_ddl_transaction!
+
+  def up
+    # This index may not exists (see migration 20171122120436)
+    remove_index :statuses, [:account_id, :reblog_of_id] if index_exists?(:statuses, [:account_id, :reblog_of_id])
+
+    remove_index :statuses, :reblog_of_id
+  end
+
+  def down
+    add_index :statuses, :reblog_of_id, algorithm: :concurrently
+  end
+end
diff --git a/db/migrate/20171129172043_add_index_on_stream_entries.rb b/db/migrate/20171129172043_add_index_on_stream_entries.rb
new file mode 100644
index 000000000..478530c7f
--- /dev/null
+++ b/db/migrate/20171129172043_add_index_on_stream_entries.rb
@@ -0,0 +1,7 @@
+class AddIndexOnStreamEntries < ActiveRecord::Migration[5.1]
+  def change
+    commit_db_transaction
+    add_index :stream_entries, [:account_id, :activity_type, :id], algorithm: :concurrently
+    remove_index :stream_entries, name: :index_stream_entries_on_account_id
+  end
+end