1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/lib/active_record/tasks
John Hawthorn 69700c9ee7 Move DatabaseAlreadyExists detection to DB adapter
Previously it was the responsibility of the database tasks to translate
the invalid statement from creating a duplicate database into an
ActiveRecord::Tasks::DatabaseAlreadyExists error.

It's actually easier for us to do this detection inside of the adapter,
where we already do a case statement on the return code to translate the
error.

This commit introduces ActiveRecord::DatabaseAlreadyExists, a subclass
of StatementInvalid, and updates both AbstractMysqlAdapter and
PostgresqlAdapter to return this more specific exception in that case.

Because this is a subclass of the old exception, StatementInvalid, it
should be backwards compatible with any code expecting that from
create_database.

This works for both create_database and exectute("CREATE DATABASE")
2019-07-29 08:40:57 -07:00
..
database_tasks.rb Move DatabaseAlreadyExists detection to DB adapter 2019-07-29 08:40:57 -07:00
mysql_database_tasks.rb Move DatabaseAlreadyExists detection to DB adapter 2019-07-29 08:40:57 -07:00
postgresql_database_tasks.rb Move DatabaseAlreadyExists detection to DB adapter 2019-07-29 08:40:57 -07:00
sqlite_database_tasks.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00