Database connection pool refactor (#5274)

* Move optimise out of RunAllMigrations
* Separate read and write database connections
* Enforce readonly connection constraint
* Fix migrations not using tx
* #5155 - allow setting cache size from environment
* Document new environment variable
This commit is contained in:
WithoutPants
2024-09-20 12:56:26 +10:00
committed by GitHub
parent 7152be6086
commit 476688c84d
10 changed files with 207 additions and 178 deletions

View File

@@ -48,7 +48,7 @@ func (m *schema60Migrator) migrate(ctx context.Context) error {
if err := m.withTxn(ctx, func(tx *sqlx.Tx) error {
query := "SELECT id, mode, find_filter, object_filter, ui_options FROM `saved_filters` WHERE `name` = ''"
rows, err := m.db.Query(query)
rows, err := tx.Query(query)
if err != nil {
return err
}
@@ -98,7 +98,7 @@ func (m *schema60Migrator) migrate(ctx context.Context) error {
// remove the default filters from the database
query = "DELETE FROM `saved_filters` WHERE `name` = ''"
if _, err := m.db.Exec(query); err != nil {
if _, err := tx.Exec(query); err != nil {
return fmt.Errorf("deleting default filters: %w", err)
}