|
|
3 years ago | |
|---|---|---|
| .. | ||
| src | 1447c5949e add migration type custom | 3 years ago |
| README.md | b3e61bb8ab create README.md | 3 years ago |
Warning Migration is applied in this way only to the latest revision. Past revisions are not applied.
git clone https://github.com/weseek/growi
cd growi/bin/data-migrations/v6
NETWORK=growi_devcontainer_default \
MONGO_URI=mongodb://growi_devcontainer_mongo_1/growi \
docker run --rm \
--network $NETWORK \
-v "$(pwd)"/src:/opt \
-w /opt \
-e MIGRATION_TYPE=v6 \
mongo:6.0 \
/bin/mongosh $MONGO_URI migration.js
| Variable | Description | Default |
|---|---|---|
| NETWORK | Network in docker compose of MongoDB server | - |
| MONGO_URI | URI that can connect to MongoDB | - |
| Variable | Description | Default |
|---|---|---|
| MIGRATION_TYPE | Migrated notation | - |
The value of MIGRATION_TYPE is one of the following.
v6-drawio: Migration of Draw.io notation only(
reference)v6-plantuml: Migration of PlantUML notation only(
reference)v6-tsv: Migration of table notation by TSV only(
reference)v6-csv: Migration of table notation by CSV only(
reference)v6-bracketlink: Migration of only page links within GROWI(
reference)v6: Migration of all the above notationscustom: You can define your own processors and apply them to revision (see "Advanced" below for details)| Variable | Description | Default |
|---|---|---|
| BATCH_SIZE | Number of revisions to be processed at one time(revision) | 100 |
| BATCH_INTERVAL | Interval after batch processing(ms) | 3000 |
※The BATCH_INTERVAL is for server load control. If the target MongoDB is used by multiple GROWI, or if there is no problem if GROWI crashes, there is no problem to shorten it.
By creating a function in growi/bin/data-migrations/v6/src/processor.js that replaces a specific regular expression, you can replace all specific strings in all recent revisions.
The following function replaces the string foo with the string bar.
function customProcessor(body) {
var fooRegExp = /foo/g; // foo regex
return body.replace(fooRegExp, 'bar'); // replace to bar
}
By passing custom in the environment variable MIGRATION_TYPE and executing it, you can apply the customProcessor to all the latest revisions.
git clone https://github.com/weseek/growi
cd growi/bin/data-migrations/v6
NETWORK=growi_devcontainer_default \
MONGO_URI=mongodb://growi_devcontainer_mongo_1/growi \
docker run --rm \
--network $NETWORK \
-v "$(pwd)"/src:/opt \
-w /opt \
-e MIGRATION_TYPE=custom \
mongo:6.0 \
/bin/mongosh $MONGO_URI migration.js