如何在 Rails 应用程序的测试数据库中创建持久表? [英] How do I create a persistent table in a Rails app's test database?

查看:34
本文介绍了如何在 Rails 应用程序的测试数据库中创建持久表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个引用 TMY3 气象数据集的 rails 应用程序,这是针对 1000 多个不同地点的大量不同的每小时天气观测数据.

I have a rails app that references the TMY3 meteorological dataset, which is a ton of different hourly weather observations for over 1000 different sites.

我下载了整个数据集并将我需要的列提取到一个按站点索引的本地表中,这使得它在开发和生产中都非常好且快速.

I downloaded the entire dataset and sucked the columns I need into a local table that is indexed by site, which makes it nice and fast in dev and in production.

然而,索引需要 5 分钟,这使得每次加载进行测试都非常痛苦.这个表永远不会改变,所以我只想将它加载到我的测试环境中,然后将它留在那里运行我的其余测试.我所有的其他模型和桌子都是标准的导轨交易,可根据需要进行工厂化或模拟.

However, the indexing takes a good 5 minutes, which makes it a HUGE pain to load in every time for tests. This table never changes, so I'd like to just load it once into my testing environment and then leave it there to run the rest of my tests against. All my other models and tables are standard rails dealies that get factoried or mocked as needed.

有什么想法吗?

推荐答案

您可能会看到 这个关于 db:test:prepare 的问题适用于您的情况.

You might see if this question about db:test:prepare applies to your situation.

这篇关于如何在 Rails 应用程序的测试数据库中创建持久表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆