126 lines
3.7 KiB
Markdown
126 lines
3.7 KiB
Markdown
# Strapi Content Migration Guide
|
|
|
|
This guide will help you migrate all content from your old Strapi server to a new one.
|
|
|
|
## Quick Start
|
|
|
|
### Step 1: Set Up Environment Variables
|
|
|
|
Create a `.env.local` file in the project root (or set environment variables):
|
|
|
|
```env
|
|
# Your new Strapi server URL
|
|
NEXT_PUBLIC_STRAPI_BASE_URL=https://your-new-strapi-server.com
|
|
|
|
# Migration script variables
|
|
OLD_STRAPI_URL=https://career.tech4bizsolutions.com
|
|
NEW_STRAPI_URL=https://your-new-strapi-server.com
|
|
NEW_STRAPI_API_TOKEN=your-api-token-here
|
|
```
|
|
|
|
**Getting an API Token:**
|
|
1. Log into your new Strapi admin panel
|
|
2. Go to Settings → API Tokens
|
|
3. Create a new token with "Full access" or appropriate permissions
|
|
4. Copy the token and add it to your `.env.local` file
|
|
|
|
### Step 2: Run the Migration
|
|
|
|
You have three options:
|
|
|
|
#### Option A: Full Migration (Export + Import)
|
|
```bash
|
|
npm run migrate
|
|
```
|
|
|
|
#### Option B: Export Only (to review data first)
|
|
```bash
|
|
npm run migrate:export
|
|
```
|
|
This creates a `scripts/strapi-export` directory with JSON files containing all content.
|
|
|
|
#### Option C: Import Only (if you already exported)
|
|
```bash
|
|
npm run migrate:import
|
|
```
|
|
|
|
## What Gets Migrated
|
|
|
|
The migration script handles these content types:
|
|
- **schoolforschools** - Main hero section content (used in `main-hero.tsx`)
|
|
- **whyschoolforschools** - Why SFS section content (used in `hero-section.tsx`)
|
|
|
|
## After Migration
|
|
|
|
1. **Update your environment variable** to point to the new server:
|
|
```env
|
|
NEXT_PUBLIC_STRAPI_BASE_URL=https://your-new-strapi-server.com
|
|
```
|
|
|
|
2. **Restart your Next.js dev server** to pick up the new environment variable:
|
|
```bash
|
|
npm run dev
|
|
```
|
|
|
|
3. **Verify the content** by checking your website - both sections should now be pulling from the new Strapi server.
|
|
|
|
## Important Notes
|
|
|
|
### Media Files
|
|
- **Media files (images) are NOT automatically migrated**
|
|
- You'll need to:
|
|
1. Export media files from the old Strapi server
|
|
2. Upload them to the new Strapi media library
|
|
3. Update any media references in the migrated content
|
|
|
|
### Content Structure
|
|
- Make sure your new Strapi server has the same content type structure (fields, relations, etc.)
|
|
- The content types must exist in the new Strapi before running the import
|
|
|
|
### Testing
|
|
- Always test the migration on a staging/test server first
|
|
- Verify all content appears correctly before switching production
|
|
|
|
## Troubleshooting
|
|
|
|
### "API Token Invalid" Error
|
|
- Verify the token is correct in your `.env.local` file
|
|
- Check that the token has proper permissions in Strapi admin panel
|
|
- Ensure the token hasn't expired
|
|
|
|
### "Content Type Not Found" Error
|
|
- Make sure the content types exist in your new Strapi server
|
|
- Verify the content type names match exactly (case-sensitive)
|
|
|
|
### "Failed to Upload" Errors
|
|
- Check the console output for specific error messages
|
|
- Verify field types match between old and new Strapi
|
|
- Some fields may need manual adjustment (dates, relations, etc.)
|
|
|
|
### Empty Export
|
|
- Verify the old Strapi URL is correct
|
|
- Check that the content types exist and have published content
|
|
- Ensure the old Strapi server is accessible
|
|
|
|
## Manual Steps (if needed)
|
|
|
|
If the automated migration doesn't work, you can:
|
|
|
|
1. **Export manually:**
|
|
- Visit `https://old-server.com/api/schoolforschools?populate=*`
|
|
- Save the JSON response
|
|
- Repeat for `whyschoolforschools`
|
|
|
|
2. **Import manually:**
|
|
- Use Strapi admin panel to create entries
|
|
- Or use Strapi's import/export plugin if available
|
|
|
|
## Support
|
|
|
|
For issues specific to:
|
|
- **Migration script**: Check `scripts/README.md`
|
|
- **Strapi API**: Refer to [Strapi Documentation](https://docs.strapi.io)
|
|
- **Next.js configuration**: Check `next.config.mjs` and environment variables
|
|
|
|
|