<!-- Authored with Coder Agents on behalf of @Emyrk --> Refs https://linear.app/codercom/issue/CORE-634/upgrade-embedded-postgresql-to-a-non-eol-version. Precedes #32144. Refuse to start built-in PostgreSQL when an existing data directory has a missing or unsupported version, rather than letting embedded-postgres replace its data. - An existing `PG_VERSION` other than 13, including 18 or 19, now returns an error without starting PostgreSQL. - A missing marker also returns recovery guidance instead of initializing over existing data. - Fresh databases and existing PostgreSQL 13 databases keep their current behavior. - Development database recovery uses the same guard. <details><summary>Agent context</summary> The bundled embedded-postgres v1 library can delete an existing data directory whose version does not match its PostgreSQL 13 binary. This change checks the directory before invoking the library, without changing the binary version or migrating data. Only Coder builds containing this guard gain the protection; already-released older binaries remain unchanged. </details> --- <sub>Coder Agents on behalf of @Emyrk.</sub>
22 lines
532 B
Go
22 lines
532 B
Go
package config_test
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/coder/coder/v2/cli/config"
|
|
)
|
|
|
|
func TestValidateBuiltinPostgresVersionAcceptsExisting13(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
postgresPath := t.TempDir()
|
|
dataPath := filepath.Join(postgresPath, "data")
|
|
require.NoError(t, os.Mkdir(dataPath, 0o700))
|
|
require.NoError(t, os.WriteFile(filepath.Join(dataPath, "PG_VERSION"), []byte("13\n"), 0o600))
|
|
require.NoError(t, config.ValidateBuiltinPostgresVersion(postgresPath))
|
|
}
|