Class: UnreadMigration
- Inherits:
-
Object
- Object
- UnreadMigration
- Defined in:
- lib/generators/unread/migration/templates/migration.rb
Class Method Summary collapse
Class Method Details
.create_options ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/generators/unread/migration/templates/migration.rb', line 16 def self. = '' if defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter) \ && ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::Mysql2Adapter) = 'DEFAULT CHARSET=latin1' end end |
.down ⇒ Object
12 13 14 |
# File 'lib/generators/unread/migration/templates/migration.rb', line 12 def self.down drop_table ReadMark end |
.up ⇒ Object
2 3 4 5 6 7 8 9 10 |
# File 'lib/generators/unread/migration/templates/migration.rb', line 2 def self.up create_table ReadMark, force: true, options: do |t| t.references :readable, polymorphic: { null: false } t.references :reader, polymorphic: { null: false } t.datetime :timestamp, null: false end add_index ReadMark, [:reader_id, :reader_type, :readable_type, :readable_id], name: 'read_marks_reader_readable_index', unique: true end |