A Migration Generator and Database Access Layer Generator for Go projects. Made with ❤️ to hopefully make your life a little bit easier.
Your Database access layer generated by yoyo
...
- provides a native, fluent query generator
- is totally pure Go
- is totally reflection-free
Okay, accessing databases in code is annoying. Relational data is annoying. It doesn't matter which language you're using. It doesn't matter if you're using PostgreSQL, MySQL, or Clickhouse, there's an innate complexity in relational data that is simply not native to Go or most other general purpose programming languages. That's why many of us turn to tools like ORMs, choosing to accept the cons of ORM magic because of the pros of having something else do the translation.
While yoyo is not an ORM, it is meant to address the same problem in a different way. By generating a database access layer with entities for your project, tailor-made to your schema and without any reflection in sight.
yoyo is a code-generation tool which really does two things:
- Help manage your schema by generating migrations.
- Help you work with your schema by generating database access layer code in your project.
yoyo's main function is generating database access code.
Read an existing database and attempt to translate it to a schema in yoyo.yml
Configuration for yoyo is kept in your project's yoyo.yml
file.
When running or generating migrations, Yoyo's connection to your database is environment-driven and managed internally.
When running as a part of your app, Yoyo cedes control for your flexibility. Therefore, it needs
to be handed a connection in the form of a *sql.DB
.
- Anything that crosses into another database. Yoyo is a single-database (single-schema) tool, so something like a MySQL Foreign Key that references a table in a different schema won't work in Yoyo.