Sha256: 56377df06fe36cb40839ff0e1db15ac16569c71c6826e44a77cf5bf42fb25445

Contents?: true

Size: 1.32 KB

Versions: 7

Compression:

Stored size: 1.32 KB

Contents

module Shamu
  module Events
    module ActiveRecord

      # Prepare the database for storing event messages.
      class Migration < ::ActiveRecord::Migration

        self.verbose = false

        # rubocop:disable Metrics/MethodLength

        def up
          return if table_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.timestamp :last_processed_at
            t.integer   :last_processed_id
            t.string    :id, null: false

            t.index :id, unique: true
          end
        end

        def down
          drop_table Message.table_name if table_exists? Message.table_name
          drop_table Channel.table_name if table_exists? Channel.table_name
          drop_table Runner.table_name  if table_exists? Runner.table_name
        end

      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
shamu-0.0.9 lib/shamu/events/active_record/migration.rb
shamu-0.0.8 lib/shamu/events/active_record/migration.rb
shamu-0.0.7 lib/shamu/events/active_record/migration.rb
shamu-0.0.5 lib/shamu/events/active_record/migration.rb
shamu-0.0.4 lib/shamu/events/active_record/migration.rb
shamu-0.0.3 lib/shamu/events/active_record/migration.rb
shamu-0.0.2 lib/shamu/events/active_record/migration.rb