我们正在使用Rake::Task['db:create'].enhance
添加新架构并在新创建的架构中创建扩展,如下所示。
Rake::Task['db:create'].enhance do
ActiveRecord::Base.connection.execute('CREATE SCHEMA IF NOT EXISTS shared_extensions;')
ActiveRecord::Base.connection.execute('CREATE EXTENSION IF NOT EXISTS "uuid-ossp" SCHEMA shared_extensions;')
end
我们能否以同样的方式增强测试数据库的准备?
答案 0 :(得分:0)
在Wiki中为公寓宝石找到了答案。
Rake::Task["db:test:purge"].enhance do
ActiveRecord::Base.connection.execute('CREATE SCHEMA IF NOT EXISTS shared_extensions;')
ActiveRecord::Base.connection.execute('CREATE EXTENSION IF NOT EXISTS "uuid-ossp" SCHEMA shared_extensions;')
end