We have a bunch of migrations (200+) which most of them are there to change the data in the database and that affect our testing. For example we have a migration like this one
public function up()
{
$deleteId = DB::table('lookups')
->where('code', '=', 'VI')
->where('type', '=', 'country')
->where('value', '=', 'U.S. Virgin Islands')
->first(['id'])->id;
DB::table('lookups')
->where('id', '=', $deleteId ?? 0)
->update(['deleted_at' => Carbon::now()->toDateTimeLocalString()]);
}
As you can see this will throw an error if we run it in the testing env. because the record does not exists in the testing environment. (we are using faker for that purpose). and my question is, should we some how skip this kind of migrations or what is the best solution?
Aucun commentaire:
Enregistrer un commentaire