Sha256: 6b1c5520dc92e8a52a81a2b855934e9c2a9bdecb3aa3fab6128f8682c4cf650c

Contents?: true

Size: 572 Bytes

Versions: 25

Compression:

Stored size: 572 Bytes

Contents

class AddContentStateField < ActiveRecord::Migration
  class Content < ActiveRecord::Base
    include BareMigration
  end

  def self.up
    modify_tables_and_update(:add_column, Content,
                             :state, :text) do |content|
      unless $schema_generator
        if content.published?
          content.state = 'Published'
        elsif content.published_at
          content.state = 'PublicationPending'
        else
          content.state = 'Draft'
        end
      end
    end
  end

  def self.down
    remove_column :contents, :state
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
typo-5.5 db/migrate/047_add_content_state_field.rb
typo-5.4.4 db/migrate/047_add_content_state_field.rb
typo-5.4.3 db/migrate/047_add_content_state_field.rb
typo-5.4.2 db/migrate/047_add_content_state_field.rb
typo-5.4.1 db/migrate/047_add_content_state_field.rb
typo-5.4 db/migrate/047_add_content_state_field.rb
typo-4.0.1 db/migrate/047_add_content_state_field.rb
typo-4.0.2 db/migrate/047_add_content_state_field.rb
typo-4.0.0 db/migrate/047_add_content_state_field.rb
typo-4.1.1 db/migrate/047_add_content_state_field.rb
typo-4.0.3 db/migrate/047_add_content_state_field.rb
typo-4.1 db/migrate/047_add_content_state_field.rb
typo-5.0.1 db/migrate/047_add_content_state_field.rb
typo-5.0.2 db/migrate/047_add_content_state_field.rb
typo-5.0.3.98.1 db/migrate/047_add_content_state_field.rb
typo-5.0 db/migrate/047_add_content_state_field.rb
typo-5.0.3.98 db/migrate/047_add_content_state_field.rb
typo-5.1.1 db/migrate/047_add_content_state_field.rb
typo-5.1.2 db/migrate/047_add_content_state_field.rb
typo-5.1.3 db/migrate/047_add_content_state_field.rb