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

Fill the database with sample data on startup #3

Open
teobais opened this issue Oct 19, 2020 · 20 comments
Open

Fill the database with sample data on startup #3

teobais opened this issue Oct 19, 2020 · 20 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed ready for work

Comments

@teobais
Copy link
Member

teobais commented Oct 19, 2020

At the moment, we need to manually run the following query (Spring Boot MongoDB example) once the server is up :

db.gods.insertMany([{ "_id" : ObjectId("5f789b086997ea37498ed9a2"), "name" : "Zeus", "power" : "justice" },{ "_id" : ObjectId("5f789b316997ea37498ed9a3"), "name" : "Hera", "power" : "childbirth", "_class" : "org.jnosql.demo.endgame.spring.data.God" },{ "_id" : ObjectId("5f789b806997ea37498ed9a4"), "name" : "Poseidon", "power" : "hurricane" },{ "_id" : ObjectId("5f789b926997ea37498ed9a5"), "name" : "Demeter", "power" : "harvest" }, { "_id" : ObjectId("5f789ba16997ea37498ed9a6"), "name" : "Athena", "power" : "wisdom" },{ "_id" : ObjectId("5f789bb16997ea37498ed9a7"), "name" : "Apollo", "power" : "light" },{ "_id" : ObjectId("5f78a318a8577a08354131b8"), "name" : "John Doe", "_class" : "org.jnosql.demo.endgame.spring.data.God" },{ "_id" : ObjectId("5f78a359a8577a08354131b9"), "name" : "Sally Doe", "_class" : "org.jnosql.demo.endgame.spring.data.God" }])

Same applies to the Sprint Neo4J example; we manually play the :movies step so it can fill in the database with some sample data once the server is started.

It would be nice to automate these steps so that the database has some initial data on startup.

@teobais teobais added good first issue Good for newcomers spring labels Oct 19, 2020
@keilw
Copy link
Collaborator

keilw commented Oct 19, 2020

Maybe with something like Liquibase, but not sure about its NoSQL support, see https://forum.liquibase.org/t/extending-liquibase-to-support-nosql-databases/2106/8

@Tegridy
Copy link

Tegridy commented Oct 23, 2020

Hi, can i try this one ?

@keilw
Copy link
Collaborator

keilw commented Oct 23, 2020

Sure, what do you wanna use?

@Tegridy
Copy link

Tegridy commented Oct 23, 2020

I wanna use Mongock. Could you also assign me and add hacktoberfest label please ?

@keilw
Copy link
Collaborator

keilw commented Oct 23, 2020

Ok, so it's only for MongoDB, why not. What's that label, I am not sure, if we need all those labels or is there a benefit like getting something by GitHub if we do that?

@keilw keilw added help wanted Extra attention is needed and removed spring labels Oct 23, 2020
@Tegridy
Copy link

Tegridy commented Oct 23, 2020

Its event on GitHub during October, and lets users win prizes by doing PR to Open Source so there is chance that more people will help with your project. Hactoberfest info

@keilw
Copy link
Collaborator

keilw commented Oct 23, 2020

Ok if we can win something why not, but October is almost over, do you think you'd still qualify or have something to show before the end of next week?O;-)

@keilw
Copy link
Collaborator

keilw commented Oct 23, 2020

@Tegridy It does not really matter adding it here, but you should add the "hacktoberfest" label to a PR which needs to come in and be merged before Oct 31.

@Tegridy
Copy link

Tegridy commented Oct 23, 2020

Yes, I came up only with Spring+Mongo solution because i don't know the other frameworks so sorry if it is a problem.

@keilw
Copy link
Collaborator

keilw commented Nov 5, 2020

@Tegridy Unfortunately mocking is not what @thodorisbais had in mind. It was more about an actual test data generation, any idea if you could come up with that, too?

@ThirumlaDevi
Copy link

@thodorisbais @keilw From this reference, I could infer that the local setup currently demands mongodb to be be installed and setup with basic test data. Why don't we dockerise mongo with volume (so that the user doesn't loose any data). docker-compose configs lets you run migrations after setting up a DB. Could you please let me know if this would solve your issue?

@teobais
Copy link
Member Author

teobais commented Mar 26, 2021

@ThirumlaDevi sounds like a good idea. I'd be happy to review a PR introducing this change. Is this something you could help us with?

@ThirumlaDevi
Copy link

@thodorisbais Sure. I'll be happy to and i'll get back to you in case of any queries. Also, could you please assign this issue to me?

@teobais
Copy link
Member Author

teobais commented Mar 26, 2021

You're all set @ThirumlaDevi !

@ThirumlaDevi
Copy link

Hi @thodorisbais. I have made the needed docker changes and I am able to migrate all data with a single command. But I am however facing issues with building and bringing up the spring boot project. This is my first time working with this framework. Could you please help me with building the spring-mongo project? This was the only reference I could find in your project. TIA.

@keilw
Copy link
Collaborator

keilw commented Mar 27, 2021

@Tegridy @thodorisbais I'm a little confused, why would it need Docker? So far the demos are all independent from Docker and I hope they also stay that way. Mongock sounds reasonable because it is a bit like Liquibase for MongoDB, but squeezing Docker in for no good reason I would not do that.

@ThirumlaDevi
Copy link

ThirumlaDevi commented Mar 27, 2021

@keilw I just thought that the project needed a local mongodb setup with pre-fiiled data and that runs on any OS platform. Hence, as per my knowledge I suggested that a docker setup would satisfy this.
I did not look into Mongock as you pointed out here that this is not what you were looking for.

@keilw
Copy link
Collaborator

keilw commented Mar 27, 2021

@ThirumlaDevi No, it's the opposite, I said here earlier "Maybe with something like Liquibase" and Mongock sounds platform-neutral while Docker is tied to Linux, please let's not blow up the example with it that way
I know, some think it's cool "Yes, great let's get Docker into everything" but it makes it harder to run those demos when we need them in a quick time, so please let's not add any burden here. All those Spring Boot Starters including the ones @thodorisbais and others used as a basis or https://github.com/okta/okta-spring-boot just to take one example do not require Docker, so let's not overcomplicate things here either.

@ThirumlaDevi I only mentioned we should not use mocking, but I hope you even looked at Mongock which is

a java MongoDB tool for tracking, managing and applying database schema changes accross all your environments based on a coding approach.

And that's exactly what we could need here, not Docker.
Looking at #4 it seems there was no Docker pollution there, so please why not continue @Tegridy's PR and forget about the Dockerization because it would make the examples more complicated. And if neither Spring, nor Helidon or Quarkus mandate it there's probably a good reason why;-)

Check out the Quarkus guides where some have an optional use of Docker. There must not be a mandatory use of Docker here,

@ThirumlaDevi
Copy link

@keilw Thank you for explaining your concern with my solution and providing some references for understanding purpose. As you pointed out @Tegridy's PR doesn't have any Docker intervention. But, there seems to be few information missing from local dummy date setup missing in PR #4. As I am not familiar with spring boot to further help you with this issue, I'll un-assign myself from this issue. Thanks for both of your time.

@ThirumlaDevi ThirumlaDevi removed their assignment Mar 27, 2021
@keilw
Copy link
Collaborator

keilw commented Mar 27, 2021

@ThirumlaDevi Thanks for your understanding. If you are not familiar with Spring Boot or Spring Data it may be better. Thanks for trying to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed ready for work
Projects
None yet
Development

No branches or pull requests

4 participants