Sha256: 87e0826954e9bb8996743cf7ff4a7414e9a7a11c941139d5789ddf604d939ca3

Contents?: true

Size: 486 Bytes

Versions: 14

Compression:

Stored size: 486 Bytes

Contents

# frozen_string_literal: true

class AddOrganizationCustomReference < ActiveRecord::Migration[5.0]
  class Organization < ApplicationRecord
    self.table_name = :decidim_organizations
  end

  def change
    add_column :decidim_organizations, :reference_prefix, :string

    Organization.find_each do |organization|
      organization.update_attributes!(reference_prefix: organization.name[0])
    end

    change_column_null :decidim_organizations, :reference_prefix, false
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
decidim-core-0.9.3 db/migrate/20170215115407_add_organization_custom_reference.rb
decidim-core-0.9.2 db/migrate/20170215115407_add_organization_custom_reference.rb
decidim-core-0.9.1 db/migrate/20170215115407_add_organization_custom_reference.rb
decidim-core-0.9.0 db/migrate/20170215115407_add_organization_custom_reference.rb
decidim-core-0.8.4 db/migrate/20170215115407_add_organization_custom_reference.rb
decidim-core-0.8.3 db/migrate/20170215115407_add_organization_custom_reference.rb
decidim-core-0.8.2 db/migrate/20170215115407_add_organization_custom_reference.rb
decidim-core-0.8.1 db/migrate/20170215115407_add_organization_custom_reference.rb
decidim-core-0.8.0 db/migrate/20170215115407_add_organization_custom_reference.rb
decidim-core-0.7.4 db/migrate/20170215115407_add_organization_custom_reference.rb
decidim-core-0.7.3 db/migrate/20170215115407_add_organization_custom_reference.rb
decidim-core-0.7.2 db/migrate/20170215115407_add_organization_custom_reference.rb
decidim-core-0.7.1 db/migrate/20170215115407_add_organization_custom_reference.rb
decidim-core-0.7.0 db/migrate/20170215115407_add_organization_custom_reference.rb