github.com/postmates/migrate@v3.0.2-0.20200730201548-1a6ead3e680d+incompatible/database/util.go (about)

     1  package database
     2  
     3  import (
     4  	"fmt"
     5  	"hash/crc32"
     6  )
     7  
     8  const advisoryLockIdSalt uint = 1486364155
     9  
    10  // inspired by rails migrations, see https://goo.gl/8o9bCT
    11  func GenerateAdvisoryLockId(databaseName string) (string, error) {
    12  	sum := crc32.ChecksumIEEE([]byte(databaseName))
    13  	sum = sum * uint32(advisoryLockIdSalt)
    14  	return fmt.Sprintf("%v", sum), nil
    15  }