Skip to content

Feature/multiproxy migration#1651

Merged
brylie merged 5 commits intodevelopfrom
feature/multiproxy-migration
Sep 29, 2016
Merged

Feature/multiproxy migration#1651
brylie merged 5 commits intodevelopfrom
feature/multiproxy-migration

Conversation

@jykae
Copy link
Copy Markdown
Contributor

@jykae jykae commented Sep 28, 2016

Closes #1436

@jykae jykae added this to the Sprint 32 milestone Sep 28, 2016
@jykae
Copy link
Copy Markdown
Contributor Author

jykae commented Sep 28, 2016

Whether it would be nicer to have control as a maintainer to decide when to run migrations, command line usage is still possible with external script:
https://github.com/percolatestudio/meteor-migrations#command-line-use

Now migrations run in startup always.

@bajiat bajiat assigned jykae and brylie and unassigned jykae Sep 29, 2016
@brylie
Copy link
Copy Markdown
Contributor

brylie commented Sep 29, 2016

Move the migrations folder into core.

@brylie
Copy link
Copy Markdown
Contributor

brylie commented Sep 29, 2016

Remove console logs. We should consider storing log statements using some other method later. For now, we are avoiding console statements.

const ApiBackends = new Mongo.Collection('apiBackends');

// Iterate through apiBackends collection
ApiBackends.find().forEach((apiBackend) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To reduce the number of characters here, and improve readability, rename apiBackend to api inside of the forEach() loop.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In any case, make sure that ApiBackends.find() returns what you are expecting (an array of API Backends). Collection.find() typically returns a collection cursor, while Collection.find().fetch() will return an array of results.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brylie I iterate through old apiBackends collection, and thought "apiBackend" is different from our new "api". You want different naming for those?
"apiBackend" -> "api" and "api" -> "apiMigration" ?

// Construct apiUrl
const apiUrl = `${apiBackend.backend_protocol}://${apiBackend.backend_host}`;
// New api object
const api = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With respect to the above comment, rename this variable as apiMigration or something similar.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That way, lines 51-64 can be a bit shorter.


// Insert migrated api, get Id
const apiId = Apis.insert(api);
console.log(`Api ${apiId} inserted`);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove console.log().


// Insert migrated proxyBackend
const proxyBackendId = ProxyBackends.insert(proxyBackend, { validate: false });
console.log(`ProxyBackend ${proxyBackendId} inserted`);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove console.log()

@brylie
Copy link
Copy Markdown
Contributor

brylie commented Sep 29, 2016

This looks really good. The only feedback is minor, to improve readability and follow our linting guidelines.

const ApiBackends = new Mongo.Collection('apiBackends');

// Iterate through apiBackends collection
ApiBackends.find().forEach((apiBackend) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In any case, make sure that ApiBackends.find() returns what you are expecting (an array of API Backends). Collection.find() typically returns a collection cursor, while Collection.find().fetch() will return an array of results.

@brylie
Copy link
Copy Markdown
Contributor

brylie commented Sep 29, 2016

Double check that Array.forEach() will work as you expect in server code.

@jykae
Copy link
Copy Markdown
Contributor Author

jykae commented Sep 29, 2016

@brylie
Copy link
Copy Markdown
Contributor

brylie commented Sep 29, 2016

Alright. Move migrations into core, and we can merge.

@jykae
Copy link
Copy Markdown
Contributor Author

jykae commented Sep 29, 2016

@brylie Done.

@brylie brylie merged commit 1738824 into develop Sep 29, 2016
@brylie brylie deleted the feature/multiproxy-migration branch September 29, 2016 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants