86 lines
2.0 KiB
Markdown
86 lines
2.0 KiB
Markdown
# Strapi Migration Scripts
|
|
|
|
This directory contains scripts to migrate content from one Strapi server to another.
|
|
|
|
## Prerequisites
|
|
|
|
1. Node.js installed
|
|
2. Access to both old and new Strapi servers
|
|
3. API token for the new Strapi server (if authentication is required)
|
|
|
|
## Setup
|
|
|
|
1. Create a `.env` file in the project root (or set environment variables):
|
|
|
|
```env
|
|
|
|
NEW_STRAPI_URL=https://your-new-strapi-server.com
|
|
NEW_STRAPI_API_TOKEN=your-api-token-here
|
|
```
|
|
|
|
## Usage
|
|
|
|
### Export Only
|
|
|
|
Export content from the old Strapi server:
|
|
|
|
```bash
|
|
node scripts/migrate-strapi.js export
|
|
```
|
|
|
|
This will create a `strapi-export` directory with JSON files containing all content.
|
|
|
|
### Import Only
|
|
|
|
Import previously exported content to the new Strapi server:
|
|
|
|
```bash
|
|
node scripts/migrate-strapi.js import
|
|
```
|
|
|
|
### Full Migration
|
|
|
|
Export and import in one command:
|
|
|
|
```bash
|
|
node scripts/migrate-strapi.js migrate
|
|
```
|
|
|
|
## Content Types Migrated
|
|
|
|
The script migrates the following content types:
|
|
- `schoolforschools` - Main hero section content
|
|
- `whyschoolforschools` - Why SFS section content
|
|
|
|
## Notes
|
|
|
|
- The script handles Strapi v4 format by default
|
|
- Media files (images) are not automatically migrated - you'll need to manually upload them or use Strapi's media library migration tools
|
|
- Relations between content types may need manual adjustment after migration
|
|
- Always test the migration on a staging server first
|
|
|
|
## Troubleshooting
|
|
|
|
### Authentication Errors
|
|
|
|
If you get 401/403 errors, make sure:
|
|
- `NEW_STRAPI_API_TOKEN` is set correctly
|
|
- The API token has proper permissions in Strapi
|
|
- The content type permissions allow creation via API
|
|
|
|
### Missing Content
|
|
|
|
If some content doesn't migrate:
|
|
- Check the console output for specific errors
|
|
- Verify the content type names match exactly
|
|
- Ensure `populate=*` is working on the source server
|
|
|
|
### Media Files
|
|
|
|
Media files need separate handling:
|
|
1. Export media files from old Strapi
|
|
2. Upload to new Strapi media library
|
|
3. Update media references in migrated content
|
|
|
|
|