module ROM::SQL
Constants
- CheckConstraintError
- ConstraintError
- DatabaseError
- ERROR_MAP
- ForeignKeyConstraintError
- MigrationError
- MissingConfigurationError
- MissingPrimaryKeyError
- NoAssociationError
- NotNullConstraintError
- UniqueConstraintError
- UnknownDBTypeError
- UnsupportedConversion
- VERSION
Attributes
current_gateway[RW]
@api private
Public Class Methods
migration(*args, &block)
click to toggle source
Trap for the migration runner. By default migrations are bound to the gateway you're using to run them. You also can explicitly pass a configuration object and a gateway name but this normally won't be not required.
@example
# Ordinary migration ROM::SQL.migration do change do create_table(:users) do primary_key :id String :name end end end
@example
# Providing a config rom = ROM::Configuration.new( default: [:sql, 'sqlite::memory'], other: [:sql, 'postgres://localhost/test'] ) # default gateway migrations ROM::SQL.migration(rom) do change do create_table(:users) do primary_key :id String :name end end end # other gateway migrations ROM::SQL.migration(rom, :other) do change do create_table(:users) do primary_key :id String :name end end end
@overload migration(container, gateway)
@param [ROM::Container] container The container instance used for accessing gateways @param [Symbol] gateway The gateway name, :default by default
@api public
# File lib/rom/sql/migration.rb, line 57 def migration(*args, &block) if args.any? container, gateway, * = args with_gateway(container.gateways[gateway || :default]) { migration(&block) } else current_gateway.migration(&block) end end
with_gateway(gateway) { || ... }
click to toggle source
This method is used on loading migrations. Temporally sets the global “current_gateway”, you shouln't access it.
@api private
# File lib/rom/sql/migration.rb, line 73 def with_gateway(gateway) current = @current_gateway @current_gateway = gateway yield ensure @current_gateway = current end