Sha256: b8394d1b4f00315eb66dd82747c4c2a584060792f6cf7c290ddc2957f98097e0

Contents?: true

Size: 825 Bytes

Versions: 52

Compression:

Stored size: 825 Bytes

Contents

class CreateForemanTasksLinks < ActiveRecord::Migration[4.2]
  def change
    # rubocop:disable Rails/CreateTableWithTimestamps
    create_table :foreman_tasks_links do |t|
      task_id_options = { :index => true, :null => true }
      if on_postgresql?
        t.uuid :task_id, task_id_options
      else
        t.string :task_id, task_id_options
      end
      t.string :resource_type
      t.integer :resource_id
    end
    # rubocop:enable Rails/CreateTableWithTimestamps

    add_index :foreman_tasks_links, [:resource_type, :resource_id]
    add_index :foreman_tasks_links, [:task_id, :resource_type, :resource_id],
              :unique => true, :name => 'foreman_tasks_links_unique_index'
  end

  private

  def on_postgresql?
    ActiveRecord::Base.connection.adapter_name.casecmp('postgresql').zero?
  end
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
foreman-tasks-8.1.2 db/migrate/20181206123910_create_foreman_tasks_links.foreman_tasks.rb
foreman-tasks-8.1.1 db/migrate/20181206123910_create_foreman_tasks_links.foreman_tasks.rb
foreman-tasks-8.1.0 db/migrate/20181206123910_create_foreman_tasks_links.foreman_tasks.rb
foreman-tasks-8.0.2 db/migrate/20181206123910_create_foreman_tasks_links.foreman_tasks.rb
foreman-tasks-8.0.1 db/migrate/20181206123910_create_foreman_tasks_links.foreman_tasks.rb
foreman-tasks-8.0.0 db/migrate/20181206123910_create_foreman_tasks_links.foreman_tasks.rb
foreman-tasks-7.2.1 db/migrate/20181206123910_create_foreman_tasks_links.foreman_tasks.rb
foreman-tasks-7.1.1 db/migrate/20181206123910_create_foreman_tasks_links.foreman_tasks.rb
foreman-tasks-7.2.0 db/migrate/20181206123910_create_foreman_tasks_links.foreman_tasks.rb
foreman-tasks-7.1.0 db/migrate/20181206123910_create_foreman_tasks_links.foreman_tasks.rb
foreman-tasks-6.0.3 db/migrate/20181206123910_create_foreman_tasks_links.foreman_tasks.rb
foreman-tasks-7.0.0 db/migrate/20181206123910_create_foreman_tasks_links.foreman_tasks.rb
foreman-tasks-6.0.2 db/migrate/20181206123910_create_foreman_tasks_links.foreman_tasks.rb
foreman-tasks-4.1.6 db/migrate/20181206123910_create_foreman_tasks_links.foreman_tasks.rb
foreman-tasks-5.2.3 db/migrate/20181206123910_create_foreman_tasks_links.foreman_tasks.rb
foreman-tasks-6.0.1 db/migrate/20181206123910_create_foreman_tasks_links.foreman_tasks.rb
foreman-tasks-5.2.2 db/migrate/20181206123910_create_foreman_tasks_links.foreman_tasks.rb
foreman-tasks-6.0.0 db/migrate/20181206123910_create_foreman_tasks_links.foreman_tasks.rb
foreman-tasks-5.2.1 db/migrate/20181206123910_create_foreman_tasks_links.foreman_tasks.rb
foreman-tasks-5.3.0 db/migrate/20181206123910_create_foreman_tasks_links.foreman_tasks.rb