Sha256: a57eddebf5588052d7b507d9a607776366df42572fde6bcbb7e3061c90a0ece5

Contents?: true

Size: 1.66 KB

Versions: 18

Compression:

Stored size: 1.66 KB

Contents

# frozen_string_literal: true

require 'thredded/base_migration'

class UpgradeV09ToV010 < Thredded::BaseMigration
  def up
    remove_foreign_key :thredded_messageboard_users, :thredded_messageboards
    add_foreign_key :thredded_messageboard_users, :thredded_messageboards,
                    column: :thredded_messageboard_id, on_delete: :cascade
    remove_foreign_key :thredded_messageboard_users, :thredded_user_details
    add_foreign_key :thredded_messageboard_users, :thredded_user_details,
                    column: :thredded_user_detail_id, on_delete: :cascade

    create_table :thredded_user_post_notifications do |t|
      t.references :user, null: false, index: false, type: user_id_type
      t.references :post, null: false, index: false, type: column_type(:thredded_posts, :id)
      t.datetime :notified_at, null: false
      t.index :post_id, name: :index_thredded_user_post_notifications_on_post_id
      t.index %i[user_id post_id], name: :index_thredded_user_post_notifications_on_user_id_and_post_id, unique: true
    end

    add_foreign_key :thredded_user_post_notifications,
                    Thredded.user_class.table_name, column: :user_id, on_delete: :cascade
    add_foreign_key :thredded_user_post_notifications,
                    :thredded_posts, column: :post_id, on_delete: :cascade
  end

  def down
    drop_table :thredded_user_post_notifications

    remove_foreign_key :thredded_messageboard_users, :thredded_user_details
    add_foreign_key :thredded_messageboard_users, :thredded_user_details
    remove_foreign_key :thredded_messageboard_users, :thredded_messageboards
    add_foreign_key :thredded_messageboard_users, :thredded_messageboards
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
thredded-0.16.9 db/upgrade_migrations/20170125033319_upgrade_v0_9_to_v0_10.rb
thredded-0.16.8 db/upgrade_migrations/20170125033319_upgrade_v0_9_to_v0_10.rb
thredded-0.16.7 db/upgrade_migrations/20170125033319_upgrade_v0_9_to_v0_10.rb
thredded-0.16.6 db/upgrade_migrations/20170125033319_upgrade_v0_9_to_v0_10.rb
thredded-0.16.5 db/upgrade_migrations/20170125033319_upgrade_v0_9_to_v0_10.rb
thredded-0.16.4 db/upgrade_migrations/20170125033319_upgrade_v0_9_to_v0_10.rb
thredded-0.16.3 db/upgrade_migrations/20170125033319_upgrade_v0_9_to_v0_10.rb
thredded-0.16.1 db/upgrade_migrations/20170125033319_upgrade_v0_9_to_v0_10.rb
thredded-0.16.0 db/upgrade_migrations/20170125033319_upgrade_v0_9_to_v0_10.rb
thredded-0.15.5 db/upgrade_migrations/20170125033319_upgrade_v0_9_to_v0_10.rb
thredded-0.15.4 db/upgrade_migrations/20170125033319_upgrade_v0_9_to_v0_10.rb
thredded-0.15.3 db/upgrade_migrations/20170125033319_upgrade_v0_9_to_v0_10.rb
thredded-0.15.2 db/upgrade_migrations/20170125033319_upgrade_v0_9_to_v0_10.rb
thredded-0.15.1 db/upgrade_migrations/20170125033319_upgrade_v0_9_to_v0_10.rb
threddedDANIEL-0.14.5 db/upgrade_migrations/20170125033319_upgrade_v0_9_to_v0_10.rb
thredded-0.14.4 db/upgrade_migrations/20170125033319_upgrade_v0_9_to_v0_10.rb
thredded-0.14.3 db/upgrade_migrations/20170125033319_upgrade_v0_9_to_v0_10.rb
thredded-0.14.2 db/upgrade_migrations/20170125033319_upgrade_v0_9_to_v0_10.rb