Sha256: 87b9d6cda0efd566f8a562af2d6fda6abeb32915441cc945e2766f6356655792

Contents?: true

Size: 846 Bytes

Versions: 7

Compression:

Stored size: 846 Bytes

Contents

module Dynamoid
  module Tasks
    module Database
      extend self

      # Create any new tables for the models. Existing tables are not
      # modified.
      def create_tables
        results = { created: [], existing: [] }
        # We can't quite rely on Dynamoid.included_models alone, we need to select only viable models
        Dynamoid.included_models.select{ |m| not m.base_class.try(:name).blank? }.uniq(&:table_name).each do |model|
          if Dynamoid.adapter.list_tables.include? model.table_name
            results[:existing] << model.table_name
          else
            model.create_table
            results[:created] << model.table_name
          end
        end
        results
      end

      # Is the DynamoDB reachable?
      def ping
        Dynamoid.adapter.list_tables
        true
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
dynamoid-2.2.0 lib/dynamoid/tasks/database.rb
dynamoid-2.1.0 lib/dynamoid/tasks/database.rb
dynamoid-2.0.0 lib/dynamoid/tasks/database.rb
dynamoid-1.3.4 lib/dynamoid/tasks/database.rb
dynamoid-1.3.3 lib/dynamoid/tasks/database.rb
dynamoid-1.3.2 lib/dynamoid/tasks/database.rb
dynamoid-1.3.1 lib/dynamoid/tasks/database.rb