-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat: AutoMigrate Automatically Generates Corresponding Table Structure Based on Model Struct Fields #3973
base: master
Are you sure you want to change the base?
Conversation
…ble Structure Based on Model Struct Fields
…ble Structure Based on Model Struct Fields
typeMapping和框架推荐的一些最佳实践不太一致,例如ORM文档中的:
而且mapping的做法和各个数据库的耦合很大,不利于后续添加其他数据库驱动,要做gdb migration的话感觉会需要一些基于驱动的映射机制,改动会比较大。 以及GoFrame应该是不会内置migration功能的,很多issue都讨论过这个问题 #3627 要用的话不如试试引入其它的migration项目吧哈哈哈 |
typeMapping is not consistent with some best practices recommended by the framework, such as in the ORM documentation:
Moreover, the mapping method is highly coupled with each database, which is not conducive to the subsequent addition of other database drivers. If you want to do gdb migration, it seems that some driver-based mapping mechanisms will be needed, and the changes will be relatively large. And GoFrame should not have built-in migration function. Many issues have discussed this issue #3627 If you want to use it, why not try introducing other migration projects hahaha |
有用过其他的migration项目哈,只不过不想每弄一个项目都额外引入三方库 1.我的感觉最佳实践 对单一的库是可以的,每个库的类型不同,不过这里为了适配多数库,主要保持golang类型与数据库类型的映射,这一版自用 也就经常用到内存库和 mysql |
I have used other migration projects, but I don’t want to introduce additional third-party libraries for every project.
|
@Royal-go 你好,感谢参与开源贡献!你的代码我看了,整体思路不错的。但是耦合有一点大。并且你这里只有 因此,如果需要实现一个相对完善的 但是 感兴趣可以尝试使用 |
Hello @Royal-go, thanks for participating in the open source contribution! I've read your code and the overall idea is good. But the coupling is a bit big. And you only have the |
平常写数据处理工具很多,给 goframe orm增加一个 根据结构体生成表的方法,这样减少一些繁琐的创建表操作,在 gdb 里面的model上 增加了一个方法AutoMigrate , 实现类似 gorm 根据实体 创建表的方法