2023-05-28 19:59:57 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"blackforestbytes.com/simplecloudnotifier/db/schema"
|
|
|
|
"context"
|
2024-07-16 17:19:55 +02:00
|
|
|
"database/sql"
|
2023-05-28 19:59:57 +02:00
|
|
|
"fmt"
|
2024-07-16 17:19:55 +02:00
|
|
|
"github.com/glebarez/go-sqlite"
|
2024-06-01 01:01:58 +02:00
|
|
|
"gogs.mikescher.com/BlackForestBytes/goext/exerr"
|
2024-07-16 17:19:55 +02:00
|
|
|
"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{})
|
|
|
|
|
2024-09-20 23:50:34 +02:00
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 1011*time.Second)
|
2023-05-28 19:59:57 +02:00
|
|
|
defer cancel()
|
|
|
|
|
2024-07-16 17:19:55 +02:00
|
|
|
if !langext.InArray("sqlite3", sql.Drivers()) {
|
|
|
|
sqlite.RegisterAsSQLITE3()
|
|
|
|
}
|
2024-06-01 01:01:58 +02:00
|
|
|
|
2024-09-20 23:50:34 +02:00
|
|
|
for key, schemaObj := range langext.AsSortedBy(langext.MapToArr(schema.PrimarySchema), func(v langext.MapEntry[int, schema.Def]) int { return v.Key }) {
|
|
|
|
var h0 string
|
|
|
|
if key == 1 {
|
|
|
|
h0 = "N/A"
|
|
|
|
} else {
|
|
|
|
var err error
|
|
|
|
h0, err = sq.HashGoSqliteSchema(ctx, schemaObj.Value.SQL)
|
|
|
|
if err != nil {
|
|
|
|
h0 = "ERR"
|
|
|
|
}
|
2023-07-27 17:44:06 +02:00
|
|
|
}
|
2024-09-20 23:50:34 +02:00
|
|
|
fmt.Printf("PrimarySchema [%d] := %s%s\n", schemaObj.Key, h0, langext.Conditional(schemaObj.Key == schema.PrimarySchemaVersion, " (active)", ""))
|
2023-07-27 17:44:06 +02:00
|
|
|
}
|
2024-06-01 01:01:58 +02:00
|
|
|
|
2024-09-20 23:50:34 +02:00
|
|
|
fmt.Printf("\n")
|
|
|
|
|
|
|
|
for _, schemaObj := range langext.AsSortedBy(langext.MapToArr(schema.RequestsSchema), func(v langext.MapEntry[int, schema.Def]) int { return v.Key }) {
|
|
|
|
h0, err := sq.HashGoSqliteSchema(ctx, schemaObj.Value.SQL)
|
2023-05-28 19:59:57 +02:00
|
|
|
if err != nil {
|
|
|
|
h0 = "ERR"
|
|
|
|
}
|
2024-09-20 23:50:34 +02:00
|
|
|
fmt.Printf("RequestsSchema [%d] := %s%s\n", schemaObj.Key, h0, langext.Conditional(schemaObj.Key == schema.RequestsSchemaVersion, " (active)", ""))
|
2023-05-28 19:59:57 +02:00
|
|
|
}
|
2024-06-01 01:01:58 +02:00
|
|
|
|
2024-09-20 23:50:34 +02:00
|
|
|
fmt.Printf("\n")
|
|
|
|
|
|
|
|
for _, schemaObj := range langext.AsSortedBy(langext.MapToArr(schema.LogsSchema), func(v langext.MapEntry[int, schema.Def]) int { return v.Key }) {
|
|
|
|
h0, err := sq.HashGoSqliteSchema(ctx, schemaObj.Value.SQL)
|
2023-05-28 19:59:57 +02:00
|
|
|
if err != nil {
|
|
|
|
h0 = "ERR"
|
|
|
|
}
|
2024-09-20 23:50:34 +02:00
|
|
|
fmt.Printf("LogsSchema [%d] := %s%s\n", schemaObj.Key, h0, langext.Conditional(schemaObj.Key == schema.LogsSchemaVersion, " (active)", ""))
|
2023-05-28 19:59:57 +02:00
|
|
|
}
|
2024-06-01 01:01:58 +02:00
|
|
|
|
2024-09-20 23:50:34 +02:00
|
|
|
fmt.Printf("\n")
|
2023-05-28 19:59:57 +02:00
|
|
|
}
|