Compare commits

..

No commits in common. "test/max_open_conn_1" and "master" have entirely different histories.

11 changed files with 88 additions and 79 deletions

View File

@ -15,46 +15,39 @@ import (
func main() { func main() {
exerr.Init(exerr.ErrorPackageConfigInit{}) exerr.Init(exerr.ErrorPackageConfigInit{})
ctx, cancel := context.WithTimeout(context.Background(), 1011*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel() defer cancel()
if !langext.InArray("sqlite3", sql.Drivers()) { if !langext.InArray("sqlite3", sql.Drivers()) {
sqlite.RegisterAsSQLITE3() sqlite.RegisterAsSQLITE3()
} }
for key, schemaObj := range langext.AsSortedBy(langext.MapToArr(schema.PrimarySchema), func(v langext.MapEntry[int, schema.Def]) int { return v.Key }) { fmt.Println()
var h0 string
if key == 1 { for i := 2; i <= schema.PrimarySchemaVersion; i++ {
h0 = "N/A" h0, err := sq.HashGoSqliteSchema(ctx, schema.PrimarySchema[i].SQL)
} else {
var err error
h0, err = sq.HashGoSqliteSchema(ctx, schemaObj.Value.SQL)
if err != nil { if err != nil {
h0 = "ERR" h0 = "ERR"
} }
} fmt.Printf("PrimarySchema%d := %s\n", i, h0)
fmt.Printf("PrimarySchema [%d] := %s%s\n", schemaObj.Key, h0, langext.Conditional(schemaObj.Key == schema.PrimarySchemaVersion, " (active)", ""))
} }
fmt.Printf("\n") for i := 1; i <= schema.RequestsSchemaVersion; i++ {
h0, err := sq.HashGoSqliteSchema(ctx, schema.RequestsSchema[i].SQL)
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)
if err != nil { if err != nil {
h0 = "ERR" h0 = "ERR"
} }
fmt.Printf("RequestsSchema [%d] := %s%s\n", schemaObj.Key, h0, langext.Conditional(schemaObj.Key == schema.RequestsSchemaVersion, " (active)", "")) fmt.Printf("RequestsSchema%d := %s\n", i, h0)
} }
fmt.Printf("\n") for i := 1; i <= schema.LogsSchemaVersion; i++ {
h0, err := sq.HashGoSqliteSchema(ctx, schema.LogsSchema[i].SQL)
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)
if err != nil { if err != nil {
h0 = "ERR" h0 = "ERR"
} }
fmt.Printf("LogsSchema [%d] := %s%s\n", schemaObj.Key, h0, langext.Conditional(schemaObj.Key == schema.LogsSchemaVersion, " (active)", "")) fmt.Printf("LogsSchema%d := %s\n", i, h0)
} }
fmt.Printf("\n") fmt.Println()
} }

View File

@ -73,7 +73,7 @@ var configLocHost = func() Config {
Journal: "WAL", Journal: "WAL",
Timeout: 5 * time.Second, Timeout: 5 * time.Second,
CheckForeignKeys: false, CheckForeignKeys: false,
SingleConn: true, SingleConn: false,
MaxOpenConns: 5, MaxOpenConns: 5,
MaxIdleConns: 5, MaxIdleConns: 5,
ConnMaxLifetime: 60 * time.Minute, ConnMaxLifetime: 60 * time.Minute,
@ -86,7 +86,7 @@ var configLocHost = func() Config {
Journal: "DELETE", Journal: "DELETE",
Timeout: 5 * time.Second, Timeout: 5 * time.Second,
CheckForeignKeys: false, CheckForeignKeys: false,
SingleConn: true, SingleConn: false,
MaxOpenConns: 5, MaxOpenConns: 5,
MaxIdleConns: 5, MaxIdleConns: 5,
ConnMaxLifetime: 60 * time.Minute, ConnMaxLifetime: 60 * time.Minute,
@ -99,7 +99,7 @@ var configLocHost = func() Config {
Journal: "DELETE", Journal: "DELETE",
Timeout: 5 * time.Second, Timeout: 5 * time.Second,
CheckForeignKeys: false, CheckForeignKeys: false,
SingleConn: true, SingleConn: false,
MaxOpenConns: 5, MaxOpenConns: 5,
MaxIdleConns: 5, MaxIdleConns: 5,
ConnMaxLifetime: 60 * time.Minute, ConnMaxLifetime: 60 * time.Minute,
@ -145,7 +145,7 @@ var configLocDocker = func() Config {
Journal: "WAL", Journal: "WAL",
Timeout: 5 * time.Second, Timeout: 5 * time.Second,
CheckForeignKeys: false, CheckForeignKeys: false,
SingleConn: true, SingleConn: false,
MaxOpenConns: 5, MaxOpenConns: 5,
MaxIdleConns: 5, MaxIdleConns: 5,
ConnMaxLifetime: 60 * time.Minute, ConnMaxLifetime: 60 * time.Minute,
@ -158,7 +158,7 @@ var configLocDocker = func() Config {
Journal: "DELETE", Journal: "DELETE",
Timeout: 5 * time.Second, Timeout: 5 * time.Second,
CheckForeignKeys: false, CheckForeignKeys: false,
SingleConn: true, SingleConn: false,
MaxOpenConns: 5, MaxOpenConns: 5,
MaxIdleConns: 5, MaxIdleConns: 5,
ConnMaxLifetime: 60 * time.Minute, ConnMaxLifetime: 60 * time.Minute,
@ -171,7 +171,7 @@ var configLocDocker = func() Config {
Journal: "DELETE", Journal: "DELETE",
Timeout: 5 * time.Second, Timeout: 5 * time.Second,
CheckForeignKeys: false, CheckForeignKeys: false,
SingleConn: true, SingleConn: false,
MaxOpenConns: 5, MaxOpenConns: 5,
MaxIdleConns: 5, MaxIdleConns: 5,
ConnMaxLifetime: 60 * time.Minute, ConnMaxLifetime: 60 * time.Minute,
@ -216,7 +216,7 @@ var configDev = func() Config {
Journal: "WAL", Journal: "WAL",
Timeout: 5 * time.Second, Timeout: 5 * time.Second,
CheckForeignKeys: false, CheckForeignKeys: false,
SingleConn: true, SingleConn: false,
MaxOpenConns: 5, MaxOpenConns: 5,
MaxIdleConns: 5, MaxIdleConns: 5,
ConnMaxLifetime: 60 * time.Minute, ConnMaxLifetime: 60 * time.Minute,
@ -229,7 +229,7 @@ var configDev = func() Config {
Journal: "DELETE", Journal: "DELETE",
Timeout: 5 * time.Second, Timeout: 5 * time.Second,
CheckForeignKeys: false, CheckForeignKeys: false,
SingleConn: true, SingleConn: false,
MaxOpenConns: 5, MaxOpenConns: 5,
MaxIdleConns: 5, MaxIdleConns: 5,
ConnMaxLifetime: 60 * time.Minute, ConnMaxLifetime: 60 * time.Minute,
@ -242,7 +242,7 @@ var configDev = func() Config {
Journal: "DELETE", Journal: "DELETE",
Timeout: 5 * time.Second, Timeout: 5 * time.Second,
CheckForeignKeys: false, CheckForeignKeys: false,
SingleConn: true, SingleConn: false,
MaxOpenConns: 5, MaxOpenConns: 5,
MaxIdleConns: 5, MaxIdleConns: 5,
ConnMaxLifetime: 60 * time.Minute, ConnMaxLifetime: 60 * time.Minute,
@ -288,7 +288,7 @@ var configStag = func() Config {
Journal: "WAL", Journal: "WAL",
Timeout: 5 * time.Second, Timeout: 5 * time.Second,
CheckForeignKeys: false, CheckForeignKeys: false,
SingleConn: true, SingleConn: false,
MaxOpenConns: 5, MaxOpenConns: 5,
MaxIdleConns: 5, MaxIdleConns: 5,
ConnMaxLifetime: 60 * time.Minute, ConnMaxLifetime: 60 * time.Minute,
@ -301,7 +301,7 @@ var configStag = func() Config {
Journal: "DELETE", Journal: "DELETE",
Timeout: 5 * time.Second, Timeout: 5 * time.Second,
CheckForeignKeys: false, CheckForeignKeys: false,
SingleConn: true, SingleConn: false,
MaxOpenConns: 5, MaxOpenConns: 5,
MaxIdleConns: 5, MaxIdleConns: 5,
ConnMaxLifetime: 60 * time.Minute, ConnMaxLifetime: 60 * time.Minute,
@ -314,7 +314,7 @@ var configStag = func() Config {
Journal: "DELETE", Journal: "DELETE",
Timeout: 5 * time.Second, Timeout: 5 * time.Second,
CheckForeignKeys: false, CheckForeignKeys: false,
SingleConn: true, SingleConn: false,
MaxOpenConns: 5, MaxOpenConns: 5,
MaxIdleConns: 5, MaxIdleConns: 5,
ConnMaxLifetime: 60 * time.Minute, ConnMaxLifetime: 60 * time.Minute,
@ -360,7 +360,7 @@ var configProd = func() Config {
Journal: "WAL", Journal: "WAL",
Timeout: 5 * time.Second, Timeout: 5 * time.Second,
CheckForeignKeys: false, CheckForeignKeys: false,
SingleConn: true, SingleConn: false,
MaxOpenConns: 5, MaxOpenConns: 5,
MaxIdleConns: 5, MaxIdleConns: 5,
ConnMaxLifetime: 60 * time.Minute, ConnMaxLifetime: 60 * time.Minute,
@ -373,7 +373,7 @@ var configProd = func() Config {
Journal: "DELETE", Journal: "DELETE",
Timeout: 5 * time.Second, Timeout: 5 * time.Second,
CheckForeignKeys: false, CheckForeignKeys: false,
SingleConn: true, SingleConn: false,
MaxOpenConns: 5, MaxOpenConns: 5,
MaxIdleConns: 5, MaxIdleConns: 5,
ConnMaxLifetime: 60 * time.Minute, ConnMaxLifetime: 60 * time.Minute,
@ -386,7 +386,7 @@ var configProd = func() Config {
Journal: "DELETE", Journal: "DELETE",
Timeout: 5 * time.Second, Timeout: 5 * time.Second,
CheckForeignKeys: false, CheckForeignKeys: false,
SingleConn: true, SingleConn: false,
MaxOpenConns: 5, MaxOpenConns: 5,
MaxIdleConns: 5, MaxIdleConns: 5,
ConnMaxLifetime: 60 * time.Minute, ConnMaxLifetime: 60 * time.Minute,

View File

@ -151,8 +151,6 @@ func (db *Database) Migrate(outerctx context.Context) error {
} }
currschema = currschema + 1 currschema = currschema + 1
ppReInit = true
} }
} }

View File

@ -151,8 +151,6 @@ func (db *Database) Migrate(outerctx context.Context) error {
} }
currschema = currschema + 1 currschema = currschema + 1
ppReInit = true
} }
} }

View File

@ -151,8 +151,6 @@ func (db *Database) Migrate(outerctx context.Context) error {
} }
currschema = currschema + 1 currschema = currschema + 1
ppReInit = true
} }
} }

View File

@ -1,9 +1,6 @@
package schema package schema
import ( import _ "embed"
"embed"
_ "embed"
)
type Def struct { type Def struct {
SQL string SQL string
@ -11,50 +8,75 @@ type Def struct {
MigScript string MigScript string
} }
//go:embed *.ddl //go:embed primary_1.ddl
//go:embed *.sql var primarySchema1 string
var assets embed.FS
//go:embed primary_2.ddl
var primarySchema2 string
//go:embed primary_3.ddl
var primarySchema3 string
//go:embed primary_4.ddl
var primarySchema4 string
//go:embed primary_5.ddl
var primarySchema5 string
//go:embed primary_6.ddl
var primarySchema6 string
//go:embed primary_7.ddl
var primarySchema7 string
//go:embed primary_8.ddl
var primarySchema8 string
//go:embed primary_migration_3_4.ddl
var primaryMigration_3_4 string
//go:embed primary_migration_4_5.ddl
var primaryMigration_4_5 string
//go:embed primary_migration_5_6.ddl
var primaryMigration_5_6 string
//go:embed primary_migration_6_7.ddl
var primaryMigration_6_7 string
//go:embed primary_migration_7_8.ddl
var primaryMigration_7_8 string
//go:embed requests_1.ddl
var requestsSchema1 string
//go:embed logs_1.ddl
var logsSchema1 string
var PrimarySchema = map[int]Def{ var PrimarySchema = map[int]Def{
0: {"", "", ""}, 0: {"", "", ""},
1: {readDDL("primary_1.ddl"), "f2b2847f32681a7178e405553beea4a324034915a0c5a5dc70b3c6abbcc852f2", ""}, 1: {primarySchema1, "f2b2847f32681a7178e405553beea4a324034915a0c5a5dc70b3c6abbcc852f2", ""},
2: {readDDL("primary_2.ddl"), "07ed1449114416ed043084a30e0722a5f97bf172161338d2f7106a8dfd387d0a", ""}, 2: {primarySchema2, "07ed1449114416ed043084a30e0722a5f97bf172161338d2f7106a8dfd387d0a", ""},
3: {readDDL("primary_3.ddl"), "65c2125ad0e12d02490cf2275f0067ef3c62a8522edf9a35ee8aa3f3c09b12e8", ""}, 3: {primarySchema3, "65c2125ad0e12d02490cf2275f0067ef3c62a8522edf9a35ee8aa3f3c09b12e8", ""},
4: {readDDL("primary_4.ddl"), "cb022156ab0e7aea39dd0c985428c43cae7d60e41ca8e9e5a84c774b3019d2ca", readMig("primary_migration_3_4.sql")}, 4: {primarySchema4, "cb022156ab0e7aea39dd0c985428c43cae7d60e41ca8e9e5a84c774b3019d2ca", primaryMigration_3_4},
5: {readDDL("primary_5.ddl"), "9d6217ba4a3503cfe090f72569367f95a413bb14e9effe49ffeabbf255bce8dd", readMig("primary_migration_4_5.sql")}, 5: {primarySchema5, "9d6217ba4a3503cfe090f72569367f95a413bb14e9effe49ffeabbf255bce8dd", primaryMigration_4_5},
6: {readDDL("primary_6.ddl"), "8e83d20bcd008082713f248ae8cd558335a37a37ce90bd8c86e782da640ee160", readMig("primary_migration_5_6.sql")}, 6: {primarySchema6, "8e83d20bcd008082713f248ae8cd558335a37a37ce90bd8c86e782da640ee160", primaryMigration_5_6},
7: {readDDL("primary_7.ddl"), "90d8dbc460afe025f9b74cda5c16bb8e58b178df275223bd2531907a8d8c36c3", readMig("primary_migration_6_7.sql")}, 7: {primarySchema7, "90d8dbc460afe025f9b74cda5c16bb8e58b178df275223bd2531907a8d8c36c3", primaryMigration_6_7},
8: {readDDL("primary_8.ddl"), "746f6005c7a573b8816e5993ecd1d949fe2552b0134ba63bab8b4d5b2b5058ad", readMig("primary_migration_7_8.sql")}, 8: {primarySchema8, "746f6005c7a573b8816e5993ecd1d949fe2552b0134ba63bab8b4d5b2b5058ad", primaryMigration_7_8},
} }
var PrimarySchemaVersion = len(PrimarySchema) - 1 var PrimarySchemaVersion = len(PrimarySchema) - 1
var RequestsSchema = map[int]Def{ var RequestsSchema = map[int]Def{
0: {"", "", ""}, 0: {"", "", ""},
1: {readDDL("requests_1.ddl"), "ebb0a5748b605e8215437413b738279670190ca8159b6227cfc2aa13418b41e9", ""}, 1: {requestsSchema1, "ebb0a5748b605e8215437413b738279670190ca8159b6227cfc2aa13418b41e9", ""},
} }
var RequestsSchemaVersion = len(RequestsSchema) - 1 var RequestsSchemaVersion = len(RequestsSchema) - 1
var LogsSchema = map[int]Def{ var LogsSchema = map[int]Def{
0: {"", "", ""}, 0: {"", "", ""},
1: {readDDL("logs_1.ddl"), "65fba477c04095effc3a8e1bb79fe7547b8e52e983f776f156266eddc4f201d7", ""}, 1: {logsSchema1, "65fba477c04095effc3a8e1bb79fe7547b8e52e983f776f156266eddc4f201d7", ""},
} }
var LogsSchemaVersion = len(LogsSchema) - 1 var LogsSchemaVersion = len(LogsSchema) - 1
func readDDL(name string) string {
data, err := assets.ReadFile(name)
if err != nil {
panic(err)
}
return string(data)
}
func readMig(name string) string {
data, err := assets.ReadFile(name)
if err != nil {
panic(err)
}
return string(data)
}