rails/activerecord/test/cases/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_test.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
mysql_rake_test.rb Move DatabaseAlreadyExists detection to DB adapter 2019-07-29 08:40:57 -07:00
postgresql_rake_test.rb Move DatabaseAlreadyExists detection to DB adapter 2019-07-29 08:40:57 -07:00
sqlite_rake_test.rb Prevent leaking of user's DB credentials on rails db:create failure 2018-08-29 12:40:30 +03:00