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

support migration feature #147

Merged
merged 4 commits into from
Jul 6, 2022
Merged

support migration feature #147

merged 4 commits into from
Jul 6, 2022

Conversation

alimy
Copy link
Collaborator

@alimy alimy commented Jul 6, 2022

  • support migration feature

pr特性:

  • 支持内置迁移机制

使用方式:

# 添加 Migration 功能到 Features 中 开启migrate功能
vim config.yaml
# file: config.yaml
# Features:
#   Default: ["Base", "MySQL", "Zinc", "MinIO", "LoggerZinc", "Migration"]
   
# 编译时加入migration tag编译出支持migrate功能的可执行文件
make build TAGS='migration'
release/paopao-ce

# 或者 带上migration tag直接运行
make run TAGS='migration'

注意:默认编译出来的执行文件是不内置migrate功能的,需要编译时带上migration tag才能内置支持migrage功能。

实现细节:

这里没有使用gorm内置的migrator机制,主要是使用gorm的migrator机制需要定义好相对应SQL DDL的model 结构体;
pr使用了另一种方法,基于golang-migrate实现 直接使用定义好的sql ddl文件支持migrate功能,达到一样的效果。

细节优化点:

  • 后续添加关于PostgreSQL的sql ddl 文件;
  • 目前只支持数据库ddl升级,不支持降级操作;

@alimy alimy requested a review from rocboss July 6, 2022 00:06
Copy link
Owner

@rocboss rocboss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good job!

@rocboss rocboss merged commit d973143 into rocboss:main Jul 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants