Hello,
Following the guide here Migrating to Prismic - Documentation - Prismic, I've been able to quickly create a script to import 40 document in Prismic.
Unfortunately it has been shown to be really slow.
The document custom type is a Tag with one field, a name.
This import took 7 minutes which, I think should have take way less.
So far I'm happy with my experience with Prismic but a bit worried about this performance issue.
The code is very simple and follow your documentation :
import 'dotenv/config'
import * as prismic from '@prismicio/client'
import slugify from '@sindresorhus/slugify'
import newstags from './news-tag.json' assert { type: 'json' }
const repositoryName = process.env.PRISMIC_REPO_NAME
const writeClient = prismic.createWriteClient(repositoryName, {
writeToken: process.env.PRISMIC_WRITE_TOKEN
})
const createDocument = (tag) => {
migration.createDocument(
{
uid: slugify(tag),
type: 'news_tags',
lang: 'fr-fr',
tags: [tag],
data: {
name: tag
}
},
tag
)
}
const migration = prismic.createMigration()
for (const tag of newstags) {
createDocument(tag)
}
await writeClient.migrate(migration, {
reporter: (event) => console.log(event)
})
Package.json file
{
"name": "migrate",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@prismicio/client": "^7.13.1",
"@prismicio/migrate": "^0.0.2",
"@sindresorhus/slugify": "^2.2.1",
"dotenv": "^16.4.7"
}
}
Thanks !
Gabriel