Rails 4.2 / PostgreSQL和测试数据库准备
Rails 4.2 / PostgreSQL and Test Database Preparation
我们正在使用 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
我们可以用同样的方式加强测试数据库准备吗?
在 Wiki 中找到公寓 gem 的答案。
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
我们正在使用 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
我们可以用同样的方式加强测试数据库准备吗?
在 Wiki 中找到公寓 gem 的答案。
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