mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
69700c9ee7
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") |
||
---|---|---|
.. | ||
database_tasks.rb | ||
mysql_database_tasks.rb | ||
postgresql_database_tasks.rb | ||
sqlite_database_tasks.rb |