Sha256: e2152dcdf9bc4149adaa75ba15a22a95f778dbcaefe8d412279ee879b582bc55

Contents?: true

Size: 787 Bytes

Versions: 4

Compression:

Stored size: 787 Bytes

Contents

class CreateWorkerPluginsWorkplaceLinks < ActiveRecord::Migration[5.2]
  def change
    create_table :worker_plugins_workplace_links do |t|
      t.references :workplace, index: {name: "index_on_workplace_id"}, null: false
      t.belongs_to :resource, index: {name: "index_on_resource"}, null: false, polymorphic: true

      if postgres?
        t.jsonb :custom_data
      else
        t.json :custom_data
      end

      t.timestamps
    end

    add_index :worker_plugins_workplace_links, [:workplace_id, :resource_type, :resource_id], unique: true, name: "unique_resource_on_workspace"
    add_foreign_key :worker_plugins_workplace_links, :worker_plugins_workplaces, column: "workplace_id"
  end

  def postgres?
    connection.adapter_name.downcase.include?("postgres")
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
worker_plugins-0.0.7 db/migrate/20150521114659_create_worker_plugins_workplace_links.rb
worker_plugins-0.0.6 db/migrate/20150521114659_create_worker_plugins_workplace_links.rb
worker_plugins-0.0.5 db/migrate/20150521114659_create_worker_plugins_workplace_links.rb
worker_plugins-0.0.4 db/migrate/20150521114659_create_worker_plugins_workplace_links.rb