Sha256: 7c5f84b5f8d1c765d54afa715328e18ce08a362e31f23d734fbdc0142747beca

Contents?: true

Size: 529 Bytes

Versions: 11

Compression:

Stored size: 529 Bytes

Contents

class ApiIdsMustBeUnique < ActiveRecord::Migration
  API_ID_TABLES = %w(surveys questions question_groups answers responses response_sets)

  class << self
    def up
      API_ID_TABLES.each do |table|
        add_index table, 'api_id', :unique => true, :name => api_id_index_name(table)
      end
    end

    def down
      API_ID_TABLES.each do |table|
        remove_index table, :name => api_id_index_name(table)
      end
    end

    private

    def api_id_index_name(table)
      "uq_#{table}_api_id"
    end
  end
end

Version data entries

11 entries across 11 versions & 4 rubygems

Version Path
upgrade_surveyor-1.4.2 lib/generators/surveyor/templates/db/migrate/api_ids_must_be_unique.rb
affectiva-surveyor-1.5.0.pre.disco.2 lib/generators/surveyor/templates/db/migrate/api_ids_must_be_unique.rb
hssc_surveyor-1.4.3.pre lib/generators/surveyor/templates/db/migrate/api_ids_must_be_unique.rb
hssc_surveyor-1.4.2.pre lib/generators/surveyor/templates/db/migrate/api_ids_must_be_unique.rb
hssc_surveyor-1.4.1.pre lib/generators/surveyor/templates/db/migrate/api_ids_must_be_unique.rb
surveyor-1.4.0 lib/generators/surveyor/templates/db/migrate/api_ids_must_be_unique.rb
surveyor-1.3.0 lib/generators/surveyor/templates/db/migrate/api_ids_must_be_unique.rb
surveyor-1.2.0 lib/generators/surveyor/templates/db/migrate/api_ids_must_be_unique.rb
surveyor-1.1.0 lib/generators/surveyor/templates/db/migrate/api_ids_must_be_unique.rb
surveyor-1.0.1 lib/generators/surveyor/templates/db/migrate/api_ids_must_be_unique.rb
surveyor-1.0.0 lib/generators/surveyor/templates/db/migrate/api_ids_must_be_unique.rb