Sha256: d851148ab4eb2b46a777ba35533a248f2af5ef1bac763415a9de3c5ff5ce2b72

Contents?: true

Size: 1.66 KB

Versions: 6

Compression:

Stored size: 1.66 KB

Contents

class InstallCommontator < ActiveRecord::Migration[5.2]
  def change
    create_table :commontator_threads do |t|
      t.references :commontable,
                   polymorphic: true,
                   index: { unique: true, name: 'index_commontator_threads_on_c_id_and_c_type' }
      t.references :closer, polymorphic: true

      t.datetime :closed_at

      t.timestamps null: false
    end

    create_table :commontator_comments do |t|
      t.references :thread, null: false, index: false, foreign_key: {
        to_table: :commontator_threads, on_update: :cascade, on_delete: :cascade
      }
      t.references :creator, polymorphic: true, null: false, index: false
      t.references :editor, polymorphic: true

      t.text     :body, null: false
      t.datetime :deleted_at

      t.integer :cached_votes_up, default: 0, index: true
      t.integer :cached_votes_down, default: 0, index: true

      t.timestamps null: false
    end

    add_index :commontator_comments, [ :creator_id, :creator_type, :thread_id ],
              name: 'index_commontator_comments_on_c_id_and_c_type_and_t_id'
    add_index :commontator_comments, [ :thread_id, :created_at ]

    create_table :commontator_subscriptions do |t|
      t.references :thread, null: false, foreign_key: {
        to_table: :commontator_threads, on_update: :cascade, on_delete: :cascade
      }
      t.references :subscriber, polymorphic: true, null: false, index: false

      t.timestamps null: false
    end

    add_index :commontator_subscriptions, [ :subscriber_id, :subscriber_type, :thread_id ],
              unique: true,
              name: 'index_commontator_subscriptions_on_s_id_and_s_type_and_t_id'
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
commontator-6.1.1 db/migrate/0_install_commontator.rb
commontator-6.1.0 db/migrate/0_install_commontator.rb
commontator-6.0.1 db/migrate/0_install_commontator.rb
commontator-6.0.0 db/migrate/0_install_commontator.rb
commontator-6.0.0.pre.2 db/migrate/0_install_commontator.rb
commontator-6.0.0.pre.1 db/migrate/0_install_commontator.rb