func (l *MySQLLock) Init(lockNameList []string) {
	if !l.MySQLClient.Migrator().HasTable(&LockStore{}) {
		// Do not handle errors, because Init() can be executed multiple times
		_ = l.MySQLClient.Migrator().CreateTable(&LockStore{})
	}

	for _, lockName := range lockNameList {
		var item LockStore
		result := l.MySQLClient.Where("name = ?", lockName).Take(&item)
		if result.Error == gorm.ErrRecordNotFound {
			l.MySQLClient.Clauses(clause.OnConflict{DoNothing: true}).
				Create(&LockStore{Name: lockName, CreatedAt: time.Now()})
		}
	}
}
// Init :Create tables
// Create row record
Init :Create tables
Create row record
// Init : Create tables // Create row record
func (l *MySQLLock) Init(lockNameList []string) {
	if !l.MySQLClient.Migrator().HasTable(&LockStore{}) {
		_ = l.MySQLClient.Migrator().CreateTable(&LockStore{})
	}
	for _, lockName := range lockNameList {
		var item LockStore
		result := l.MySQLClient.Where("name = ?", lockName).Take(&item)
		if result.Error == gorm.ErrRecordNotFound {
			l.MySQLClient.Clauses(clause.OnConflict{DoNothing: true}).
				Create(&LockStore{Name: lockName, CreatedAt: time.Now()})
		}
	}
}
func ( l * MySQLLock ) Init ( lockNameList [ ] string ) { if ! l . MySQLClient . Migrator ( ) . HasTable ( & LockStore { } ) { _ = l . MySQLClient . Migrator ( ) . CreateTable ( & LockStore { } ) } for _ , lockName := range lockNameList { var item LockStore result := l . MySQLClient . Where ( " " , lockName ) . Take ( & item ) if result . Error == gorm . ErrRecordNotFound { l . MySQLClient . Clauses ( clause . OnConflict { DoNothing : true } ) . Create ( & LockStore { Name : lockName , CreatedAt : time . Now ( ) } ) } } }
Init :Create tables
Create row record
Init : Create tables Create row record
// Do not handle errors, because Init() can be executed multiple times