class UnreadMigration
Public Class Methods
create_options()
click to toggle source
# File lib/generators/unread/migration/templates/migration.rb, line 16 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
down()
click to toggle source
# File lib/generators/unread/migration/templates/migration.rb, line 12 def self.down drop_table ReadMark end
up()
click to toggle source
# File lib/generators/unread/migration/templates/migration.rb, line 2 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