我們有非常大的rails應用程序,目前我們正在從TestUnit/fixture轉換到Rspec/FactoryGirl。我們的數據庫有很多「系統」表,其中數據不變或很少更新。例如FactoryGirl,Rspec和複雜的數據庫結構
user_types
ID NAME ...
1 System Adminisrator ...
2 Organization Administrator ...
....
9 Mega Administrator ...
另外我們有很多配置表和它們之間的長引用。例如:
master_organizations many-to-many organizations has_many
plan_years has_many products has_many plans
organizations has_many employees ... and so on
而且我們需要在所有規格運行之前配置所有系統表和至少一個組織。然後,如果需要,每個套件都可以將其他數據添加到數據庫。
所以問題是如何構建一個好的,複雜的和靈活的結構,這對於開發人員是可讀的?今天,我們最接近的解決方案是將db結構創建移動到單獨的文件中:爲系統表,配置表等創建shared_contexts。然後在必要時加入。但不確定這種方法是否好。