Class: Shamu::Events::ActiveRecord::Migration
- Inherits:
-
Object
- Object
- Shamu::Events::ActiveRecord::Migration
- Defined in:
- lib/shamu/events/active_record/migration.rb
Overview
Prepare the database for storing event messages.
Instance Method Summary collapse
Instance Method Details
#down ⇒ Object
38 39 40 41 42 |
# File 'lib/shamu/events/active_record/migration.rb', line 38 def down drop_table Message.table_name if data_source_exists? Message.table_name drop_table Channel.table_name if data_source_exists? Channel.table_name drop_table Runner.table_name if data_source_exists? Runner.table_name end |
#up ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/shamu/events/active_record/migration.rb', line 10 def up return if data_source_exists? Message.table_name # TODO: Need to provide a means for using 64-bit primary keys in # databases that support it. Otherwise limited to 4B events. create_table Message.table_name do |t| t.integer :channel_id, null: false t.string :message, null: false t.index :id t.index :channel_id end create_table Channel.table_name do |t| t.string :name, null: false, unique: true t.index :name end create_table Runner.table_name, id: false do |t| t. :last_processed_at t.integer :last_processed_id t.string :id, null: false t.index :id, unique: true end end |