Module: ROM::SQL

Extended by:
Dry::Core::Extensions
Included in:
Relation
Defined in:
lib/rom/sql/dsl.rb,
lib/rom/sql/error.rb,
lib/rom/sql/types.rb,
lib/rom/sql/errors.rb,
lib/rom/sql/schema.rb,
lib/rom/sql/gateway.rb,
lib/rom/sql/version.rb,
lib/rom/sql/function.rb,
lib/rom/sql/relation.rb,
lib/rom/sql/attribute.rb,
lib/rom/sql/group_dsl.rb,
lib/rom/sql/migration.rb,
lib/rom/sql/order_dsl.rb,
lib/rom/sql/extensions.rb,
lib/rom/sql/schema/dsl.rb,
lib/rom/sql/association.rb,
lib/rom/sql/transaction.rb,
lib/rom/sql/projection_dsl.rb,
lib/rom/sql/commands/create.rb,
lib/rom/sql/commands/delete.rb,
lib/rom/sql/commands/update.rb,
lib/rom/sql/restriction_dsl.rb,
lib/rom/sql/schema/inferrer.rb,
lib/rom/sql/association/name.rb,
lib/rom/sql/relation/reading.rb,
lib/rom/sql/relation/writing.rb,
lib/rom/sql/plugin/associates.rb,
lib/rom/sql/plugin/pagination.rb,
lib/rom/sql/plugin/timestamps.rb,
lib/rom/sql/migration/migrator.rb,
lib/rom/sql/qualified_attribute.rb,
lib/rom/sql/relation/sequel_api.rb,
lib/rom/sql/commands/transaction.rb,
lib/rom/sql/association/one_to_one.rb,
lib/rom/sql/commands/error_wrapper.rb,
lib/rom/sql/association/many_to_one.rb,
lib/rom/sql/association/one_to_many.rb,
lib/rom/sql/extensions/sqlite/types.rb,
lib/rom/sql/schema/associations_dsl.rb,
lib/rom/sql/association/many_to_many.rb,
lib/rom/sql/extensions/mysql/inferrer.rb,
lib/rom/sql/extensions/postgres/types.rb,
lib/rom/sql/extensions/sqlite/inferrer.rb,
lib/rom/sql/extensions/postgres/commands.rb,
lib/rom/sql/extensions/postgres/inferrer.rb,
lib/rom/sql/association/one_to_one_through.rb,
lib/rom/sql/extensions/rails_log_subscriber.rb,
lib/rom/sql/extensions/active_support_notifications.rb

Defined Under Namespace

Modules: ActiveSupportInstrumentation, Commands, Migration, Plugin, SequelAPI, Types Classes: Association, Attribute, DSL, Error, Function, Gateway, GroupDSL, OrderDSL, ProjectionDSL, QualifiedAttribute, RailsLogSubscriber, Relation, RestrictionDSL, Schema, Transaction

Constant Summary collapse

MissingConfigurationError =
Class.new(StandardError)
NoAssociationError =
Class.new(StandardError)
DatabaseError =
Class.new(Error)
ConstraintError =
Class.new(Error)
NotNullConstraintError =
Class.new(ConstraintError)
UniqueConstraintError =
Class.new(ConstraintError)
ForeignKeyConstraintError =
Class.new(ConstraintError)
CheckConstraintError =
Class.new(ConstraintError)
UnknownDBTypeError =
Class.new(StandardError)
ERROR_MAP =
{
  Sequel::DatabaseError => DatabaseError,
  Sequel::ConstraintViolation => ConstraintError,
  Sequel::NotNullConstraintViolation => NotNullConstraintError,
  Sequel::UniqueConstraintViolation => UniqueConstraintError,
  Sequel::ForeignKeyConstraintViolation => ForeignKeyConstraintError,
  Sequel::CheckConstraintViolation => CheckConstraintError
}.freeze
VERSION =
'1.0.0'.freeze
Rollback =
Class.new(Sequel::Rollback)

Class Method Summary collapse

Class Method Details

.migration(&block) ⇒ Object

Trap for the migration runner. To create a migration on a specific gateway, use ROM::SQL::Gateway#migration

Examples:

rom = ROM.container(
  default: [:sql, 'sqlite::memory'],
  other: [:sql, 'postgres://localhost/test']
)

# default gateway migrations
ROM::SQL.migration do
  change do
    create_table(:users) do
      primary_key :id
      String :name
    end
  end
end

# other gateway migrations
rom.gateways[:other].migration do
  change do
    create_table(:users) do
      primary_key :id
      String :name
    end
  end
end


35
36
37
# File 'lib/rom/sql/migration.rb', line 35

def self.migration(&block)
  ROM::SQL::Gateway.instance.migration(&block)
end