Skip to content

Commit

Permalink
Add SQL2SQL, GH Issue Template, start working on instructions
Browse files Browse the repository at this point in the history
Signed-off-by: Derrick Mehaffy <[email protected]>
  • Loading branch information
derrickmehaffy committed Apr 29, 2022
1 parent 13b5f6a commit 3f0cab5
Show file tree
Hide file tree
Showing 32 changed files with 2,105 additions and 13 deletions.
44 changes: 44 additions & 0 deletions .github/ISSUE_TEMPLATE/BUG_REPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: 🐛 Bug Report
about: Create a report to help us improve the migration scripts.
---

## Bug report

### Required System information

- Node.js version:
- NPM version:
- Source Strapi version:
- Target Strapi version:
- Source Database:
- Target Database:
- Operating system:
- Which script are you running:

### Describe the bug

A clear and concise description of what the bug is.

### Steps to reproduce the behavior

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

### Expected behavior

A clear and concise description of what you expected to happen.

### Screenshots

If applicable, add screenshots to help explain your problem.

### Code snippets

If applicable, add code samples to help explain your problem.

### Additional context

Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
blank_issues_enabled: false
contact_links:
- name: Strapi Code Bug Report
url: https://github.com/strapi/strapi/issues/new?assignees=&labels=&template=BUG_REPORT.md
about: Create a report to help us improve Strapi.
- name: Product Feature Request
url: https://feedback.strapi.io/feature-requests
about: Provide feedback to the Strapi team and ask for new features or enhancements!
- name: Documentation Bug Report
url: https://github.com/strapi/documentation/issues/new?template=BUG_REPORT.md&title%5B%5D=BUG
about: Create a report to help us improve the Strapi documentation.
- name: Documentation Request
url: https://feedback.strapi.io/documentation
about: Suggest a new part of the documentation we are missing!
- name: Strapi Questions and Discussions
url: https://forum.strapi.io
about: Please ask and answer questions on the community forums.
- name: Join the Community Discord
url: https://discord.strapi.io
about: Come and chat with other community members!
146 changes: 145 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,147 @@
# Created by https://www.toptal.com/developers/gitignore/api/node
# Edit at https://www.toptal.com/developers/gitignore?templates=node

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

### Node Patch ###
# Serverless Webpack directories
.webpack/

# Optional stylelint cache

# SvelteKit build / generate output
.svelte-kit

# Database files
data.db
node_modules/

# End of https://www.toptal.com/developers/gitignore/api/node
29 changes: 25 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
# v3 to v4
# Strapi Migration Scripts

This repository contains notes and scripts to migration from v3 to v4
This repository contains notes and scripts to run data migrations between Strapi versions

## Links
## Supported Databases

- [Migration from MongoDB to SQL](./v3-mongo-to-sql/README.md)
When referring to `SQL` databases we mean officially supported databases by Strapi:

- MySQL >= 5.7.8
- MariaDB >= 10.2.7
- PostgreSQL >= 10
- SQLite >= 3

For more information on supported databases, please see the [deployment guidelines](https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/deployment.html#general-guidelines) in the Strapi documentation.

## Script Status

Some scripts may be in various states, *you should pay careful attention to what state the script is in as it may not have had significant testing for all use-cases*! Current script states are as follows:

- **Alpha**: We have not tested this with any "real world" like applications, only in limited environments
- **Beta**: We have tested this in a small number of "real world" like applications and/or we have had some actual users do closed beta testing on it
- **Stable**: We have had large scale testing and it is believed to be in a stable state
- **Legacy**: This script is considered EOL and will no longer be updated

## Scripts

- [Migration from v3 MongoDB to v3 SQL](./v3-mongo-to-sql/README.md) - **Currently in Alpha Testing**
- [Migration from v3 SQL to v4 SQL](./v3-sql-to-sql/README.md) - **Currently in Beta Testing**
21 changes: 13 additions & 8 deletions v3-mongo-to-sql/README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
# Migration script from Strapi v3 on mongo to Strapi v3 on SQL
# Migration script from Strapi v3 on MongoDB to Strapi v3 on SQL

> For now this works for sqlite only and can then be used to dump into pg or mysql (will automate the other two soon)
## Preparation steps

1. Preform a backup of your database you wish to migrate and store that backup somewhere secure

## Install

Requirements
### Requirements

- Nodejs v16
- Nodejs v14/v16
- Yarn


Installation
### Installation

```sh
yarn
```

## Configuration
## Instructions


## Migration

1. Start by following this guide https://www.notion.so/strapi/Mongo-to-SQL-migration-2c47f80114bb48b298edd386a47138c1 and migrate the app and generate the new DB
2. Configure the DB connections by copying `.env.example` to `.env` and updating the vars
2. Run the script
3. Run the script

```sh
node index.js
```
```
17 changes: 17 additions & 0 deletions v3-sql-to-sql/.env.mysql.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# General Settings
DATABASE_CLIENT=mysql
BATCH_SIZE=50

# V3 Settings
DATABASE_V3_HOST=127.0.0.1
DATABASE_V3_PORT=3306
DATABASE_V3_USER=strapiUser
DATABASE_V3_PASSWORD=strapiPassword
DATABASE_V3_DATABASE=strapiv3

# V4 Settings
DATABASE_V4_HOST=127.0.0.1
DATABASE_V4_PORT=3306
DATABASE_V4_USER=strapiUser
DATABASE_V4_PASSWORD=strapiPassword
DATABASE_V4_DATABASE=strapiv4
19 changes: 19 additions & 0 deletions v3-sql-to-sql/.env.pg.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# General Settings
DATABASE_CLIENT=pg
BATCH_SIZE=50

# V3 Settings
DATABASE_V3_HOST=127.0.0.1
DATABASE_V3_PORT=5432
DATABASE_V3_USER=strapiUser
DATABASE_V3_PASSWORD=strapiPassword
DATABASE_V3_DATABASE=strapiv3
DATABASE_V3_SCHEMA=public

# V4 Settings
DATABASE_V4_HOST=127.0.0.1
DATABASE_V4_PORT=5432
DATABASE_V4_USER=strapiUser
DATABASE_V4_PASSWORD=strapiPassword
DATABASE_V4_DATABASE=strapiv4
DATABASE_V4_SCHEMA=public
9 changes: 9 additions & 0 deletions v3-sql-to-sql/.env.sqlite.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# General Settings
DATABASE_CLIENT=sqlite
BATCH_SIZE=50

# V3 Settings
DATABASE_V3_PATH=/exact/path/to/your/v3/data.db

# V4 Settings
DATABASE_V4_URL=/exact/path/to/your/v4/data.db
37 changes: 37 additions & 0 deletions v3-sql-to-sql/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Migration script from Strapi v3 on SQL to Strapi v4 on SQL

## Preparation steps

- Preform a backup of your database you wish to migrate and store that backup somewhere secure

## Install

### Requirements

- Nodejs v14/v16
- Yarn

### Installation

```sh
yarn
```

## Configuration

1. Choose which database you are migrating from/to (currently this script only supports migrating to the same database type as the source)
2. Copy the corresponding `.env.DBTYPE.example` file to `.env` using something like `cp .env.pg.example .env`
3. Modify the configuration in the `.env` to match your v3 source and your v4 target databases

## Migration

1. Migrate your Strapi Code before running this script, see the following [documentation](https://docs.strapi.io/developer-docs/latest/update-migration-guides/migration-guides/v4/code-migration.html)
2. Run Strapi v4 in `develop` mode with empty DB to generate the DB structure
3. Turn off / kill the running Strapi v4 server
4. Run migration script using `yarn start`

<!-- ## (Optional) Custom migrations
1. Open customMigrations.js
2. Create your migrations as you want you have to return function migrateTables and array processedTables with processed tables
3. Databases are imported from config/database.js and using knex -->
Loading

0 comments on commit 3f0cab5

Please sign in to comment.