I’m using prisma migration and would like to move ...
# orm-help
p
I’m using prisma migration and would like to move column from one table to another together with data DB schema transformation works good, but I’s not clear for me how could I migrate the data from those columns? I guess that changing README file with sql query inside is only for information purpose is there any tutorial for this or I’m not getting the concept?
r
Hey Pavlo 👋 For this, you would have to create a seed file, something like this:
Copy code
import { PrismaClient } from '@prisma/client'

const prisma = new PrismaClient({
  log: ['query'],
})

async function main() {
  // fetch all data
  // transfer the data from the fields to the other field
}

main()
  .catch((e) => console.error('e', e))
  .finally(async () => await prisma.disconnect())
Then you can directly run this seed file, via
node seed.js
or
npx ts-node seed.ts
if using TypeScript.
p
many thanks, @Ryan!
👍 1