about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFire Demon <firedemon@creature.cafe>2020-08-01 16:12:29 -0500
committerFire Demon <firedemon@creature.cafe>2020-08-30 05:45:16 -0500
commitca72dc7334d5ee233c3fe5912a4536fc223d4fc4 (patch)
tree9c8ddddd03273fa7b8783cc5df96549627997498
parentf17bab4a35cfc168f2c2d7a22bebdfa1e8c72876 (diff)
[Database] Add missing accounts reference to publishing delay table
-rw-r--r--app/models/publishing_delay.rb10
-rw-r--r--db/migrate/20200801210543_add_accounts_to_publishing_delays.rb9
-rw-r--r--db/schema.rb5
3 files changed, 19 insertions, 5 deletions
diff --git a/app/models/publishing_delay.rb b/app/models/publishing_delay.rb
index 7b4d4c214..0f943c8ce 100644
--- a/app/models/publishing_delay.rb
+++ b/app/models/publishing_delay.rb
@@ -2,13 +2,15 @@
 #
 # Table name: publishing_delays
 #
-#  id        :bigint(8)        not null, primary key
-#  status_id :bigint(8)        not null
-#  after     :datetime
+#  id          :bigint(8)        not null, primary key
+#  status_id   :bigint(8)        not null
+#  after       :datetime
+#  accounts_id :bigint(8)        not null
 #
 
 class PublishingDelay < ApplicationRecord
-  belongs_to :status, inverse_of: :destruct
+  belongs_to :status, inverse_of: :publishing_delay
+  belongs_to :account, inverse_of: :publishing_delays
 
   validates :status_id, uniqueness: true
 end
diff --git a/db/migrate/20200801210543_add_accounts_to_publishing_delays.rb b/db/migrate/20200801210543_add_accounts_to_publishing_delays.rb
new file mode 100644
index 000000000..0c720d30c
--- /dev/null
+++ b/db/migrate/20200801210543_add_accounts_to_publishing_delays.rb
@@ -0,0 +1,9 @@
+class AddAccountsToPublishingDelays < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def change
+    safety_assured do
+      add_reference :publishing_delays, :accounts, null: false, foreign_key: { on_delete: :cascade }, index: { algorithm: :concurrently }
+    end
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 5e0bf0b13..fb280b54f 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_07_31_211100) do
+ActiveRecord::Schema.define(version: 2020_08_01_210543) do
 
   # These are extensions that must be enabled in order to support this database
   enable_extension "plpgsql"
@@ -714,6 +714,8 @@ ActiveRecord::Schema.define(version: 2020_07_31_211100) do
   create_table "publishing_delays", force: :cascade do |t|
     t.bigint "status_id", null: false
     t.datetime "after"
+    t.bigint "accounts_id", null: false
+    t.index ["accounts_id"], name: "index_publishing_delays_on_accounts_id"
     t.index ["after"], name: "index_publishing_delays_on_after"
     t.index ["status_id"], name: "index_publishing_delays_on_status_id"
   end
@@ -1077,6 +1079,7 @@ ActiveRecord::Schema.define(version: 2020_07_31_211100) do
   add_foreign_key "poll_votes", "polls", on_delete: :cascade
   add_foreign_key "polls", "accounts", on_delete: :cascade
   add_foreign_key "polls", "statuses", on_delete: :cascade
+  add_foreign_key "publishing_delays", "accounts", column: "accounts_id", on_delete: :cascade
   add_foreign_key "publishing_delays", "statuses", on_delete: :cascade
   add_foreign_key "queued_boosts", "accounts", on_delete: :cascade
   add_foreign_key "queued_boosts", "statuses", on_delete: :cascade