Sha256: 17609a0f7180b241b30d1e731eee0128cbd969842d3e6bfc03d8b880de50b5f3

Contents?: true

Size: 908 Bytes

Versions: 74

Compression:

Stored size: 908 Bytes

Contents

# frozen_string_literal: true

class MakeAuthorsPolymorphic < ActiveRecord::Migration[5.2]
  class Coauthorship < ApplicationRecord
    self.table_name = :decidim_coauthorships
  end

  def change
    remove_index :decidim_coauthorships, :decidim_author_id

    add_column :decidim_coauthorships, :decidim_author_type, :string

    reversible do |direction|
      direction.up do
        execute <<~SQL.squish
          UPDATE decidim_coauthorships
          SET decidim_author_type = 'Decidim::UserBaseEntity'
        SQL
      end
    end

    add_index :decidim_coauthorships,
              [:decidim_author_id, :decidim_author_type],
              name: "index_decidim_coauthorships_on_decidim_author"

    change_column_null :decidim_coauthorships, :decidim_author_id, false
    change_column_null :decidim_coauthorships, :decidim_author_type, false

    Coauthorship.reset_column_information
  end
end

Version data entries

74 entries across 74 versions & 1 rubygems

Version Path
decidim-core-0.25.0.rc4 db/migrate/20181016091601_make_authors_polymorphic.rb
decidim-core-0.25.0.rc3 db/migrate/20181016091601_make_authors_polymorphic.rb
decidim-core-0.25.0.rc2 db/migrate/20181016091601_make_authors_polymorphic.rb
decidim-core-0.25.0.rc1 db/migrate/20181016091601_make_authors_polymorphic.rb
decidim-core-0.24.3 db/migrate/20181016091601_make_authors_polymorphic.rb
decidim-core-0.23.6 db/migrate/20181016091601_make_authors_polymorphic.rb
decidim-core-0.24.2 db/migrate/20181016091601_make_authors_polymorphic.rb
decidim-core-0.23.5 db/migrate/20181016091601_make_authors_polymorphic.rb
decidim-core-0.24.1 db/migrate/20181016091601_make_authors_polymorphic.rb
decidim-core-0.24.0 db/migrate/20181016091601_make_authors_polymorphic.rb
decidim-core-0.24.0.rc2 db/migrate/20181016091601_make_authors_polymorphic.rb
decidim-core-0.23.4 db/migrate/20181016091601_make_authors_polymorphic.rb
decidim-core-0.24.0.rc1 db/migrate/20181016091601_make_authors_polymorphic.rb
decidim-core-0.23.3 db/migrate/20181016091601_make_authors_polymorphic.rb
decidim-core-0.23.2 db/migrate/20181016091601_make_authors_polymorphic.rb
decidim-core-0.23.1 db/migrate/20181016091601_make_authors_polymorphic.rb
decidim-core-0.23.1.rc1 db/migrate/20181016091601_make_authors_polymorphic.rb
decidim-core-0.23.0 db/migrate/20181016091601_make_authors_polymorphic.rb
decidim-core-0.22.0 db/migrate/20181016091601_make_authors_polymorphic.rb
decidim-core-0.21.0 db/migrate/20181016091601_make_authors_polymorphic.rb