Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/multiproxy migration #1651

Merged
merged 5 commits into from
Sep 29, 2016
Merged

Feature/multiproxy migration #1651

merged 5 commits into from
Sep 29, 2016

Conversation

jykae
Copy link
Contributor

@jykae jykae commented Sep 28, 2016

Closes #1436

@jykae jykae added this to the Sprint 32 milestone Sep 28, 2016
@jykae
Copy link
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
Contributor

brylie commented Sep 29, 2016

Move the migrations folder into core.

@brylie
Copy link
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
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
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
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
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
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
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
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
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
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
Contributor

brylie commented Sep 29, 2016

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

@jykae
Copy link
Contributor Author

jykae commented Sep 29, 2016

@brylie
Copy link
Contributor

brylie commented Sep 29, 2016

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

@jykae
Copy link
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
@ilarimikkonen ilarimikkonen added this to In Review in apinf/platform Apr 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants