dewv / nlcAttendance

Attendance tracking for the Naylor Learning Center at Davis & Elkins College
MIT License
2 stars 2 forks source link

Explore MongoDB/Sails configuration issues #153

Open smattingly opened 3 years ago

smattingly commented 3 years ago

When we launch the app in production set up, it says:

debug: It looks like the default datastore for this app is `sails-mongo`,
debug: but the default primary key attribute (`id`) is not set up correctly.
debug: When using `sails-mongo`, primary keys MUST have `columnName: '_id'`,
debug: and must _not_ have `autoIncrement: true`.
debug: Also, if `dontUseObjectIds` is not set to `true` for the model,
debug: then the `type` of the primary key must be `string`.
debug: 
debug: We'll set this up for you this time...

I understand what Sails wants us to do, but I'm confused why they want it. The whole point of Sails' database portions is avoiding code that is specific to one kind of database. Since they can obviously "take care of it", why not just do that? "This time" is misleading-- it always does this. So, I went ahead and switched to MongoDB with this setup.

But, I'd like to explore this to see if we can tell any difference. (For example, does this have anything to do with the slow MongoDB performance we saw?)

Here's a rough outline: (I can help with all these steps)

smattingly commented 3 years ago

Keeping @Weintraubm and @Spritte77 in the loop. I will supervise this one.

smattingly commented 3 years ago

@BroadusA Next step is to make the changes sails seems to want. In config/models.js, change the property in the attributes object from id: { type: "number", autoIncrement: true, }, to id: { type: "string", columnName: "_id", },

Next, in the config/local.js file you created, change the createTestData setting from false to true.

Finally, stop the application if it is running (Ctrl-C in the terminal), and launch it with npm start. Unless there are errors, that should recreate the database with the recommended settings. I will then look at the cloud tools to see about next steps.

BroadusA commented 3 years ago

@smattingly @Spritte77 @Weintraubm 02/15 4:15 pm. property attributes were changed and CreateTestData setting was changed.

smattingly commented 3 years ago

Ok, I can see from the database results that the code changes made no difference in the resulting database structures. So we won't need to do a redesign/update of the existing database, as I thought we might. I will work with @BroadusA to improve the code changes and test so that the code works with either MySQL or MongoDB, warning free.

smattingly commented 3 years ago

It appears that there is not a straightforward way to use different configurations depending on the database driver. The critical steps happen during initialization of the app, when info about the db driver is not yet available. I think we should pause work on this until we upgrade to the latest Sails version, then revisit it.

smattingly commented 3 years ago

We have now upgraded sails in production. I think the messages are still appearing when the app starts.