Closed MrOrz closed 1 year ago
Migration process
npm run reload -- articles
Staging running result
docker@answerfamily:~/rumors-db$ date
Wed Dec 7 10:17:44 UTC 2022
docker@answerfamily:~/rumors-db$ npm run reload -- articles
> rumors-db@1.0.2 reload
> babel-node db/reloadSchema.js "articles"
Source: articles_v1_2_0
Target: articles_v1_3_0
Reindexed from articles_v1_2_0 to articles_v1_3_0 in 64 seconds.
Setup articles_v1_3_0 -> articles alias and remove articles_v1_2_0.
docker@answerfamily:~/rumors-db$ date
Wed Dec 7 10:19:02 UTC 2022
articles.status
Migration script: Add a status="NORMAL" to those articles which don't have a status
.
curl -XPOST "http://$DB_URL/articles/_update_by_query" -H 'Content-Type: application/json' -d'
{
"script": {
"source": "ctx._source[\"status\"]=\"NORMAL\";",
"lang": "painless"
},
"query": {
"bool": {
"must_not": {
"exists": {
"field": "status"
}
}
}
}
}'
Before migration, all existing articles without status
are not listed in UI and chatbot.
Result on staging (82sec)
{"took":82330,"timed_out":false,"total":96283,"updated":96283,"deleted":0,"batches":97,"version_conflicts":0,"noops":0,"retries":{"bulk":0,"search":0},"throttled_millis":0,"requests_per_second":-1.0,"throttled_until_millis":0,"failures":[]}
docker-compose pull
& docker-compose up -d
Run the migration again to migrate new articles created between 2 and 3.
DB migrated successfully.
CreateArticle
,CreateMediaArticle
writes tostatus
fieldListArticles
addsstatuses
filter; do not list outBLOCKED
articles by defaultrelatedArticles
inArticle
do not list outBLOCKED
articles by defaultrelatedArticles
will also include blocked articles