Sha256: 2c4747e89aa789143d3f709b85588b84b2fbad1237a1c593512658eff0135bde

Contents?: true

Size: 698 Bytes

Versions: 3

Compression:

Stored size: 698 Bytes

Contents

# frozen_string_literal: true

module Hyperstack
  module ConnectionAdapter
    module ActiveRecord
      module AutoCreate
        def table_exists?
          # works with both rails 4 and 5 without deprecation warnings
          if connection.respond_to?(:data_sources)
            connection.data_sources.include?(table_name)
          else
            connection.tables.include?(table_name)
          end
        end

        def needs_init?
          Hyperstack.transport != :none && Hyperstack.on_server? && !table_exists?
        end

        def create_table(*args, &block)
          connection.create_table(table_name, *args, &block) if needs_init?
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hyper-operation-1.0.alpha1.8 lib/hyper-operation/transport/connection_adapter/active_record/auto_create.rb
hyper-operation-1.0.alpha1.7 lib/hyper-operation/transport/connection_adapter/active_record/auto_create.rb
hyper-operation-1.0.alpha1.6 lib/hyper-operation/transport/connection_adapter/active_record/auto_create.rb