hey team :wave: is there a way to backfill a newly...
# prisma-whats-new
l
hey team 👋 is there a way to backfill a newly created type, maybe based on a relation? For example, I want to create a settings type which has a one-to-one relationship with an organisation type. Can I easily backfill a settings record for each existing organisation, with some default values in the fields?
n
@lewisblackwood hey 👋
what do you mean with back filling?
ah so your organizations already exist
and now you want to create a new setting per organization with some default values
how many organizations do you have?
l
exactly 👌 around 40
n
it'll be the same exact field values for all settings, right?
l
yep!
n
cool! Then it's probably the easiest if you write a simple script that - queries all organization ids - for each organization id, runs the mutation
Copy code
mutation a {
  createSetting(title: "test", cool: true, organisationId: "<some-i>") {
    id
  }
}
l
cool 👌 will do that
n
great 🙂 here's a simple script for a different use case that might be of help: https://github.com/graphcool-examples/migration-scripts/blob/master/images/migrate-images.js
in this script the individual mutations are batched, you don't have to do that