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

Refactor admin as a component (part of Issue 2490) #2492

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Refactor admin as a component (part of Issue 2490) #2492

wants to merge 7 commits into from

Conversation

nstuyvesant
Copy link
Contributor

First modification towards 2490.. Wasn't sure whether this should go in canary or master. BTW, I found a problem in seed.js from my previous PR and will submit another to correct it.

Change app.js to seed database in promise chain before startServer, move seeding conditional to seed.js and wrap in function.
Previously, .sync() was being called once in server/config/seed.js and once during sqldb.sequelize.sync() in server/app.js. As a result, duplicate queries were being sent to the database if the tables needed to be defined causing an error when it tries to define constraints a second time (like for an identity column).

Seed.js is wrapped in a function and contains the conditional to determine whether to seed the database. This makes it easy to include in the promise chain under sqldb.sequelize.sync().
Previously, .sync() was being called once in server/config/seed.js and once during sqldb.sequelize.sync() in server/app.js. As a result, duplicate queries were being sent to the database if the tables needed to be defined causing an error when it tries to define constraints a second time (like for an identity column).

Seed.js is wrapped in a function and contains the conditional to determine whether to seed the database. This makes it easy to include in the promise chain under sqldb.sequelize.sync().
Previously, admin was implemented as a loosely coupled controller. Converting it to a full component makes it consistent with main and generated components.
For projects with auth=Y, users were not being populated for those using Sequelize because of the return on Think.bulkCreate. The return was changed to a Sequelize.Promise.all so that all the promises are properly managed.
@Awk34
Copy link
Member

Awk34 commented Feb 6, 2017

I think you should use the same model as the main component, and have the admin controller class in the same admin.component.js file.

@Awk34
Copy link
Member

Awk34 commented Feb 6, 2017

Also, you'll need to pull your latest commit for seed.js that was merged into master

@Awk34
Copy link
Member

Awk34 commented Feb 6, 2017

I've added you as a collaborator, so you can make a branch directly on this repository if you'd like.

Previously, admin was implemented as a loosely coupled controller. Converting it to a full component makes it consistent with main and generated components.
@nstuyvesant
Copy link
Contributor Author

Thanks for adding me as a contributor. I pushed an additional commit that put the controller code back into admin.module.js. Also added the corrected seed(model).js.

@nstuyvesant
Copy link
Contributor Author

Did a git revert f6da78f to undo the changes to templates/app/server/config/seed(models).js. Please let me know if that was what you were looking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants