lib/tasks/db.rake in gris-0.3.6 vs lib/tasks/db.rake in gris-0.3.7
- old
+ new
@@ -22,10 +22,18 @@
task create: :environment do
db = Gris.db_connection_details
admin_connection = db.merge(database: 'postgres',
schema_search_path: 'public')
ActiveRecord::Base.establish_connection(admin_connection)
- ActiveRecord::Base.connection.create_database(db['database'])
+ begin
+ ActiveRecord::Base.connection.create_database(db['database'])
+ rescue ActiveRecord::StatementInvalid => e
+ if e.message =~ /DuplicateDatabase/
+ $stderr.puts "#{admin_connection['database']} already exists"
+ else
+ raise
+ end
+ end
end
desc 'Delete the database'
task drop: :environment do
db = Gris.db_connection_details