mikestefanello / pagoda

Rapid, easy full-stack web development starter kit in Go
MIT License
2.21k stars 115 forks source link

Workflow on making migrations with Ent and Atlas? #37

Closed jjdechavez closed 1 year ago

jjdechavez commented 1 year ago

Thank you for a great project! This project is perfect for me as a new go developer.

I am having hard time working with migrations, especially making some seed data. May I know what are the steps on how you guys create migrations? Thank you!

So far what I have tried:

  1. atlas migrate new add-default-roles --dir "file://ent/migrate/migrations"
  2. atlas migrate hash --dir "file://ent/migrate/migrations"
  3. atlas migrate status --dir "file://ent/migrate/migrations" -u "sqlite://mydb.db"

On third, step I'm having an error: Error: sql/migrate: connected database is not clean: found multiple tables: 4. baseline version or allow-dirty is required

mikestefanello commented 1 year ago

Hey - thank you very much. I'm always glad to hear that others are finding this project useful.

My knowledge of ent/atlas is quite limited overall and probably somewhat outdated at this point so I don't think I'm the best person to be asking. Handling migrations with atlas is really an atlas specific issue as well. For this project, I just want to make sure the entity schemas are setup when the app is started. I would recommend posting an issue on the atlas project instead. They will certainly be able to assist you way better than I can. I'd also recommend checking out their Slack and Discord channels. I've gotten quick and great support from the maintainers there.

jjdechavez commented 1 year ago

Thank you for the response @mikestefanello

I just want to make sure the entity schemas are setup when the app is started.

Now, I understand how pagoda works on entity schemas. Thank you!

mikestefanello commented 1 year ago

This is where the entity schemas are created, FYI: https://github.com/mikestefanello/pagoda/blob/main/pkg/services/container.go#L174