Module: ROM::SQL

Included in:
Relation
Defined in:
lib/rom/sql/error.rb,
lib/rom/sql/types.rb,
lib/rom/sql/errors.rb,
lib/rom/sql/header.rb,
lib/rom/sql/schema.rb,
lib/rom/sql/gateway.rb,
lib/rom/sql/version.rb,
lib/rom/sql/relation.rb,
lib/rom/sql/types/pg.rb,
lib/rom/sql/migration.rb,
lib/rom/sql/schema/dsl.rb,
lib/rom/sql/association.rb,
lib/rom/sql/commands/create.rb,
lib/rom/sql/commands/delete.rb,
lib/rom/sql/commands/update.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/commands/postgres.rb,
lib/rom/sql/plugin/associates.rb,
lib/rom/sql/plugin/pagination.rb,
lib/rom/sql/migration/migrator.rb,
lib/rom/sql/plugin/assoc_macros.rb,
lib/rom/sql/qualified_attribute.rb,
lib/rom/sql/commands/transaction.rb,
lib/rom/sql/commands_ext/postgres.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/schema/associations_dsl.rb,
lib/rom/sql/association/many_to_many.rb,
lib/rom/sql/support/rails_log_subscriber.rb,
lib/rom/sql/association/one_to_one_through.rb,
lib/rom/sql/plugin/assoc_macros/class_interface.rb,
lib/rom/sql/support/active_support_notifications.rb

Defined Under Namespace

Modules: ActiveSupportInstrumentation, Commands, Migration, Plugin, Types Classes: Association, Error, Gateway, Header, QualifiedAttribute, RailsLogSubscriber, Relation, Schema

Constant Summary collapse

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)
ERROR_MAP =
{
  Sequel::DatabaseError => DatabaseError,
  Sequel::NotNullConstraintViolation => NotNullConstraintError,
  Sequel::UniqueConstraintViolation => UniqueConstraintError,
  Sequel::ForeignKeyConstraintViolation => ForeignKeyConstraintError,
  Sequel::CheckConstraintViolation => CheckConstraintError
}.freeze
VERSION =
'0.8.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.setup(
  default: [:sql, 'sqlite::memory'],
  other: [:sql, 'postgres://localhost/test']
)

ROM.finalize

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


26
27
28
# File 'lib/rom/sql/migration.rb', line 26

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