question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Refactor migrate / install scripts to keep up to SRP

See original GitHub issue
eko@eko-GE62VR-6RF:~/Schreibtisch/vue-storefront-api$ npm run migrate

> vue-storefront-api@0.1.0 migrate /home/eko/Schreibtisch/vue-storefront-api
> node node_modules/migrate/bin/migrate

Elasticsearch INFO: 2018-03-05T20:07:01Z
  Adding connection to http://localhost:9200/

  up : 1513603161654-reindex.js
Elasticsearch DEBUG: 2018-03-05T20:07:01Z
  starting request {
    "method": "POST",
    "path": "/_reindex",
    "body": {
      "source": {
        "index": "vue_storefront_catalog_temp"
      },
      "dest": {
        "index": "vue_storefront_catalog"
      }
    },
    "query": {}
  }
  

Elasticsearch DEBUG: 2018-03-05T20:07:01Z
  Request complete

{ Error: [index_not_found_exception] no such index, with { resource.type="index_or_alias" & resource.id="vue_storefront_catalog_temp" & index_uuid="_na_" & index="vue_storefront_catalog_temp" }
    at respond (/home/eko/Schreibtisch/vue-storefront-api/node_modules/elasticsearch/src/lib/transport.js:307:15)
    at checkRespForFailure (/home/eko/Schreibtisch/vue-storefront-api/node_modules/elasticsearch/src/lib/transport.js:266:7)
    at HttpConnector.<anonymous> (/home/eko/Schreibtisch/vue-storefront-api/node_modules/elasticsearch/src/lib/connectors/http.js:159:7)
    at IncomingMessage.bound (/home/eko/Schreibtisch/vue-storefront-api/node_modules/elasticsearch/node_modules/lodash/dist/lodash.js:729:21)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1055:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
  status: 404,
  displayName: 'NotFound',
  message: '[index_not_found_exception] no such index, with { resource.type="index_or_alias" & resource.id="vue_storefront_catalog_temp" & index_uuid="_na_" & index="vue_storefront_catalog_temp" }',
  path: '/_reindex',
  query: {},
  body: 
   { error: 
      { root_cause: [Array],
        type: 'index_not_found_exception',
        reason: 'no such index',
        'resource.type': 'index_or_alias',
        'resource.id': 'vue_storefront_catalog_temp',
        index_uuid: '_na_',
        index: 'vue_storefront_catalog_temp' },
     status: 404 },
  statusCode: 404,
  response: '{"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"vue_storefront_catalog_temp","index_uuid":"_na_","index":"vue_storefront_catalog_temp"}],"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"vue_storefront_catalog_temp","index_uuid":"_na_","index":"vue_storefront_catalog_temp"},"status":404}',
  toString: [Function],
  toJSON: [Function] }
  error : [index_not_found_exception] no such index, with { resource.type="index_or_alias" & resource.id="vue_storefront_catalog_temp" & index_uuid="_na_" & index="vue_storefront_catalog_temp" } :: {"path":"/_reindex","query":{},"body":"{\"source\":{\"index\":\"vue_storefront_catalog_temp\"},\"dest\":{\"index\":\"vue_storefront_catalog\"}}","statusCode":404,"response":"{\"error\":{\"root_cause\":[{\"type\":\"index_not_found_exception\",\"reason\":\"no such index\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"vue_storefront_catalog_temp\",\"index_uuid\":\"_na_\",\"index\":\"vue_storefront_catalog_temp\"}],\"type\":\"index_not_found_exception\",\"reason\":\"no such index\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"vue_storefront_catalog_temp\",\"index_uuid\":\"_na_\",\"index\":\"vue_storefront_catalog_temp\"},\"status\":404}"}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vue-storefront-api@0.1.0 migrate: `node node_modules/m

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
pkarwcommented, Jul 27, 2018

@daaru00 good point. I’ll check it. I think it should be modified - you’re right; I mean - migrations shouldn’t be related to the restore script. You could modify it if You like.

To do so You probably need to modify the installation procedure (core/scripts/installer.js + README file) and the npm run restore to sth like this:

First variant - to use the default data set - to be used by the installer:

yarn restore
yarn db rebuild
yarn db migrate

Second variant - to use the tempty data set - to be available for the manual installation:

yarn db new
yarn db migrate

Migrate script should be always at the end as there is a possibility that for example some migrations are adding specific Elastic data entities that were not available in the dump.

1reaction
pkarwcommented, Mar 5, 2018

vue_storefront_catalog_temp is created by npm run restore command and then after the migration ran its deleted

So after you run the vue-storefront installer - you will be not able to re-run the migrations without running the first step - npm run restore

Read more comments on GitHub >

github_iconTop Results From Across the Web

Refactor migrate / install scripts to keep up to SRP #28 - GitHub
Migrate script should be always at the end as there is a possibility that for example some migrations are adding specific Elastic data...
Read more >
Refactoring for SRP - SymfonyCasts
The first thing I want to do is rename register() to create() ... or you could use save() ... or even rename the...
Read more >
About the migration strategies - AWS Prescriptive Guidance
There are seven migration strategies for moving applications to the cloud, known as the 7 Rs: Retire. Retain. Rehost. Relocate. Repurchase. Replatform. Refactor...
Read more >
Migration from Entity Framework into Dapper - jtabuloc blog
Create a library project that will manage all migration scripts. This project must only contain migration scripts, and the only responsibility ...
Read more >
Refactoring - Unity - Manual
In order to fix it, you can reopen the script file and map the new name to the previous name with the [RenamedFrom]...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found