문제

I'm working on an app that must integrate with an existing database and other legacy apps. Throughout the legacy apps, implicit assumptions are made that certain records in certain tables exist.

For instance, legacy code assumes that a record with name 'Valid' exists in the table 'statuses', and a record with username 'System' exists in the users table.

As I'm digging into the legacy code, I'm writing down these implicit assumptions to make them explicit, so that I'm able to:

  • setup a small development db instead of using a dump of the very very huge production db;

  • setup a staging db (again, without the zillions of records from production);

  • run tests in a clean, predictable db.

  • be idempotent and DO NOT mess the existing db.

So the question is: what would you use to create system records if they don't exist? Would you opt for a rails migration, seeds, an initializer or what?

도움이 되었습니까?

해결책

I think seeds would be the way to go here.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top