Domanda

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?

È stato utile?

Soluzione

I think seeds would be the way to go here.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top