Sha256: 3e154772210d0e72a092018d25f072bb9be9c1e2359e462ef67e7440c0e20b6e

Contents?: true

Size: 766 Bytes

Versions: 4

Compression:

Stored size: 766 Bytes

Contents

class UnreadMigration < Unread::MIGRATION_BASE_CLASS
  def self.up
    create_table ReadMark, force: true, options: create_options do |t|
      t.references :readable, polymorphic: { null: false }
      t.references :reader,   polymorphic: { null: false }
      t.datetime :timestamp
    end

    add_index ReadMark, [:reader_id, :reader_type, :readable_type, :readable_id], name: 'read_marks_reader_readable_index', unique: true
  end

  def self.down
    drop_table ReadMark
  end

  def self.create_options
    options = ''
    if defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter) \
      && ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::Mysql2Adapter)
      options = 'DEFAULT CHARSET=latin1'
    end
    options
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
unread-0.11.0 lib/generators/unread/migration/templates/migration.rb
unread-0.10.1 lib/generators/unread/migration/templates/migration.rb
unread-0.10.0 lib/generators/unread/migration/templates/migration.rb
unread-0.9.1 lib/generators/unread/migration/templates/migration.rb