Skip to content

Commit

Permalink
feat(pro): add pro migrate and seed
Browse files Browse the repository at this point in the history
  • Loading branch information
Matrix-X committed Sep 20, 2024
1 parent d10d8a0 commit 5b4ef02
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 5 deletions.
4 changes: 4 additions & 0 deletions cmd/ctl/database/migrate/powerx.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package migrate

import (
"PowerX/cmd/ctl/database/custom/migrate"
migratePro "PowerX/cmd/ctl/database/pro/migrate"
"PowerX/internal/config"
"PowerX/internal/model"
"PowerX/internal/model/crm/customerdomain"
Expand Down Expand Up @@ -92,6 +93,9 @@ func (m *PowerMigrator) AutoMigrate() {
trade.TokenReservation{}, trade.TokenTransaction{},
)

// pro
migratePro.AutoMigratePro(m.db)

// custom
migrate.AutoMigrateCustom(m.db)

Expand Down
12 changes: 12 additions & 0 deletions cmd/ctl/database/pro/migrate/custom.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package migrate

import (
"gorm.io/gorm"
)

func AutoMigratePro(db *gorm.DB) {
// migrate your pro models

_ = db.AutoMigrate()

}
17 changes: 17 additions & 0 deletions cmd/ctl/database/pro/seed/datadictionary.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package seed

import (
"PowerX/internal/model"
"PowerX/internal/uc/powerx"
"gorm.io/gorm"
)

var UseCaseDD *powerx.DataDictionaryUseCase

func ProDataDictionary(db *gorm.DB) (data []*model.DataDictionaryType) {

UseCaseDD = powerx.NewDataDictionaryUseCase(db)

return data

}
9 changes: 9 additions & 0 deletions cmd/ctl/database/pro/seed/pro.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package seed

import (
"gorm.io/gorm"
)

func CreateProSeeds(db *gorm.DB) {

}
8 changes: 5 additions & 3 deletions cmd/ctl/database/seed/datadictionary/datadictionary.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package datadictionary

import (
"PowerX/cmd/ctl/database/custom/seed"
seedCustom "PowerX/cmd/ctl/database/custom/seed"
seedPro "PowerX/cmd/ctl/database/pro/seed"
"PowerX/internal/model"
"PowerX/internal/uc/powerx"
"PowerX/pkg/slicex"
Expand All @@ -20,8 +21,9 @@ func CreateDataDictionaries(db *gorm.DB) (err error) {

UseCaseDD = powerx.NewDataDictionaryUseCase(db)
data := DefaultDataDictionary()
customData := seed.CustomDataDictionary(db)
data = slicex.Concatenate(data, customData)
proData := seedPro.ProDataDictionary(db)
customData := seedCustom.CustomDataDictionary(db)
data = slicex.Concatenate(data, proData, customData)

if count == 0 {
if err = db.Model(&model.DataDictionaryType{}).Create(data).Error; err != nil {
Expand Down
8 changes: 6 additions & 2 deletions cmd/ctl/database/seed/powerx.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package seed

import (
"PowerX/cmd/ctl/database/custom/seed"
seedCustom "PowerX/cmd/ctl/database/custom/seed"
seedPro "PowerX/cmd/ctl/database/pro/seed"
"PowerX/cmd/ctl/database/seed/datadictionary"
"PowerX/internal/config"
"gorm.io/driver/mysql"
Expand Down Expand Up @@ -60,8 +61,11 @@ func (s *PowerSeeder) CreatePowerX() (err error) {
// Marketing
_ = CreateMGMRules(s.db)

// pro
seedPro.CreateProSeeds(s.db)

// custom
seed.CreateCustomSeeds(s.db)
seedCustom.CreateCustomSeeds(s.db)

return
}

0 comments on commit 5b4ef02

Please sign in to comment.