v0.0.350
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m2s
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m2s
This commit is contained in:
parent
05580c384a
commit
6e90239fef
@ -1,5 +1,5 @@
|
|||||||
package goext
|
package goext
|
||||||
|
|
||||||
const GoextVersion = "0.0.349"
|
const GoextVersion = "0.0.350"
|
||||||
|
|
||||||
const GoextVersionTimestamp = "2023-12-28T01:36:21+0100"
|
const GoextVersionTimestamp = "2023-12-29T18:06:45+0100"
|
||||||
|
32
sq/hasher.go
32
sq/hasher.go
@ -13,7 +13,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func HashSqliteSchema(ctx context.Context, schemaStr string) (string, error) {
|
// HashMattnSqliteSchema
|
||||||
|
// use if github.com/glebarez/go-sqlite
|
||||||
|
func HashMattnSqliteSchema(ctx context.Context, schemaStr string) (string, error) {
|
||||||
dbdir := os.TempDir()
|
dbdir := os.TempDir()
|
||||||
dbfile1 := filepath.Join(dbdir, langext.MustHexUUID()+".sqlite3")
|
dbfile1 := filepath.Join(dbdir, langext.MustHexUUID()+".sqlite3")
|
||||||
|
|
||||||
@ -39,6 +41,34 @@ func HashSqliteSchema(ctx context.Context, schemaStr string) (string, error) {
|
|||||||
return HashSqliteDatabase(ctx, db)
|
return HashSqliteDatabase(ctx, db)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HashGoSqliteSchema
|
||||||
|
// use if mattn/go-sqlite3
|
||||||
|
func HashGoSqliteSchema(ctx context.Context, schemaStr string) (string, error) {
|
||||||
|
dbdir := os.TempDir()
|
||||||
|
dbfile1 := filepath.Join(dbdir, langext.MustHexUUID()+".sqlite3")
|
||||||
|
|
||||||
|
err := os.MkdirAll(dbdir, os.ModePerm)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
url := fmt.Sprintf("file:%s?_pragma=journal_mode(%s)&_pragma=timeout(%d)&_pragma=foreign_keys(%s)&_pragma=busy_timeout(%d)", dbfile1, "DELETE", 1000, "true", 1000)
|
||||||
|
|
||||||
|
xdb, err := sqlx.Open("sqlite", url)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
db := NewDB(xdb)
|
||||||
|
|
||||||
|
_, err = db.Exec(ctx, schemaStr, PP{})
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return HashSqliteDatabase(ctx, db)
|
||||||
|
}
|
||||||
|
|
||||||
func HashSqliteDatabase(ctx context.Context, db Queryable) (string, error) {
|
func HashSqliteDatabase(ctx context.Context, db Queryable) (string, error) {
|
||||||
ss, err := CreateSqliteDatabaseSchemaString(ctx, db)
|
ss, err := CreateSqliteDatabaseSchemaString(ctx, db)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user