SimpleCloudNotifier/scnserver/cmd/dbhash/main.go

54 lines
1.2 KiB
Go
Raw Normal View History

2023-05-28 19:59:57 +02:00
package main
import (
"blackforestbytes.com/simplecloudnotifier/db/schema"
"context"
"database/sql"
2023-05-28 19:59:57 +02:00
"fmt"
"github.com/glebarez/go-sqlite"
2024-06-01 01:01:58 +02:00
"gogs.mikescher.com/BlackForestBytes/goext/exerr"
"gogs.mikescher.com/BlackForestBytes/goext/langext"
2023-05-28 19:59:57 +02:00
"gogs.mikescher.com/BlackForestBytes/goext/sq"
"time"
)
func main() {
2024-06-01 01:01:58 +02:00
exerr.Init(exerr.ErrorPackageConfigInit{})
2023-05-28 19:59:57 +02:00
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
if !langext.InArray("sqlite3", sql.Drivers()) {
sqlite.RegisterAsSQLITE3()
}
2024-06-01 01:01:58 +02:00
fmt.Println()
for i := 2; i <= schema.PrimarySchemaVersion; i++ {
h0, err := sq.HashGoSqliteSchema(ctx, schema.PrimarySchema[i].SQL)
if err != nil {
h0 = "ERR"
}
2024-06-01 01:01:58 +02:00
fmt.Printf("PrimarySchema%d := %s\n", i, h0)
}
2024-06-01 01:01:58 +02:00
for i := 1; i <= schema.RequestsSchemaVersion; i++ {
h0, err := sq.HashGoSqliteSchema(ctx, schema.RequestsSchema[i].SQL)
2023-05-28 19:59:57 +02:00
if err != nil {
h0 = "ERR"
}
2024-06-01 01:01:58 +02:00
fmt.Printf("RequestsSchema%d := %s\n", i, h0)
2023-05-28 19:59:57 +02:00
}
2024-06-01 01:01:58 +02:00
for i := 1; i <= schema.LogsSchemaVersion; i++ {
h0, err := sq.HashGoSqliteSchema(ctx, schema.LogsSchema[i].SQL)
2023-05-28 19:59:57 +02:00
if err != nil {
h0 = "ERR"
}
2024-06-01 01:01:58 +02:00
fmt.Printf("LogsSchema%d := %s\n", i, h0)
2023-05-28 19:59:57 +02:00
}
2024-06-01 01:01:58 +02:00
fmt.Println()
2023-05-28 19:59:57 +02:00
}