Sha256: 41460e7fa8e9bf680d7f544ac65ac63c95162755a01ba925083bb027000a6507

Contents?: true

Size: 1.27 KB

Versions: 4

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

class CreateVotingTables < ActiveRecord::Migration[5.0]
  def change
    create_table :voting_votes do |t|
      t.integer :negative, default: 0, null: false
      t.integer :positive, default: 0, null: false

      t.references :author,    index: true, null: false, polymorphic: true
      t.references :resource,  index: true, null: false, polymorphic: true
      t.references :scopeable, index: true, null: true,  polymorphic: true

      t.timestamps null: false
    end

    add_index :voting_votes, %i[author_id author_type resource_id resource_type scopeable_id scopeable_type],
      name:   :index_voting_votes_on_author_and_resource_and_scopeable,
      unique: true

    create_table :voting_votings do |t|
      t.decimal :estimate, default: 0, mull: false, precision: 25, scale: 20
      t.integer :negative, default: 0, null: false
      t.integer :positive, default: 0, null: false

      t.references :resource,  index: true, null: false, polymorphic: true
      t.references :scopeable, index: true, null: true,  polymorphic: true

      t.timestamps null: false
    end

    add_index :voting_votings, %i[resource_id resource_type scopeable_id scopeable_type],
      name:   :index_voting_votings_on_resource_and_scopeable,
      unique: true
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
voting-0.4.0 lib/generators/voting/templates/db/migrate/create_voting_tables.rb
voting-0.3.0 lib/generators/voting/templates/db/migrate/create_voting_tables.rb
voting-0.2.0 lib/generators/voting/templates/db/migrate/create_voting_tables.rb
voting-0.1.0 lib/generators/voting/templates/db/migrate/create_voting_tables.rb