1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-08-18 13:48:58 +02:00

task: bump minimum postgres version (#10096)

Co-authored-by: Gastón Fournier <gaston@getunleash.io>
This commit is contained in:
Christopher Kolstad 2025-06-09 11:04:47 +02:00 committed by GitHub
parent a5e5ea0436
commit 7f14cc2c3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 64 deletions

View File

@ -64,7 +64,6 @@
"seed:setup": "ts-node src/test/e2e/seed/segment.seed.ts",
"seed:serve": "UNLEASH_DATABASE_NAME=unleash_test UNLEASH_DATABASE_SCHEMA=seed yarn run start:dev",
"clean": "del-cli --force dist",
"heroku-postbuild": "cd frontend && yarn && yarn build",
"prepack": "./scripts/prepack.sh",
"schema:update": "node ./.husky/update-openapi-spec-list.js"
},

View File

@ -35,63 +35,21 @@ beforeEach(() => {
},
});
});
describe('postgres-version-checker', () => {
describe('Postgres version below 13.0 will yield error messages', () => {
test('12.1.7', async () => {
settingStore = fakeSettingStore('12.1.7');
await compareAndLogPostgresVersion(config, settingStore);
expect(errorMessages).toHaveLength(1);
expect(infoMessages).toHaveLength(0);
});
test('12.1', async () => {
settingStore = fakeSettingStore('12.1');
await compareAndLogPostgresVersion(config, settingStore);
expect(errorMessages).toHaveLength(1);
expect(infoMessages).toHaveLength(0);
});
test('11.1', async () => {
settingStore = fakeSettingStore('11.1');
await compareAndLogPostgresVersion(config, settingStore);
expect(errorMessages).toHaveLength(1);
expect(infoMessages).toHaveLength(0);
});
test('10.1', async () => {
settingStore = fakeSettingStore('10.1');
await compareAndLogPostgresVersion(config, settingStore);
expect(errorMessages).toHaveLength(1);
expect(infoMessages).toHaveLength(0);
});
test('9.6', async () => {
settingStore = fakeSettingStore('9.6');
await compareAndLogPostgresVersion(config, settingStore);
expect(errorMessages).toHaveLength(1);
expect(infoMessages).toHaveLength(0);
});
});
describe('Postgres version at 13.0 or higher will yield an info message', () => {
test('13.9.2', async () => {
settingStore = fakeSettingStore('13.9.2');
await compareAndLogPostgresVersion(config, settingStore);
expect(errorMessages).toHaveLength(0);
expect(infoMessages).toHaveLength(1);
});
test('14.9', async () => {
settingStore = fakeSettingStore('14.9');
await compareAndLogPostgresVersion(config, settingStore);
expect(errorMessages).toHaveLength(0);
expect(infoMessages).toHaveLength(1);
});
test('15.9', async () => {
settingStore = fakeSettingStore('15.9');
await compareAndLogPostgresVersion(config, settingStore);
expect(errorMessages).toHaveLength(0);
expect(infoMessages).toHaveLength(1);
});
test('16.2', async () => {
settingStore = fakeSettingStore('16.2');
await compareAndLogPostgresVersion(config, settingStore);
expect(errorMessages).toHaveLength(0);
expect(infoMessages).toHaveLength(1);
});
});
});
test.each(['13.9.2', '12.1.7', '12.1', '11.1', '10.1', '9.6'])(
'Postgres version %s yields error message',
async (version) => {
settingStore = fakeSettingStore(version);
await compareAndLogPostgresVersion(config, settingStore);
expect(errorMessages).toHaveLength(1);
expect(infoMessages).toHaveLength(0);
},
);
test.each(['14.9', '15.9', '16.2', '17'])(
'Postgres version %s yields an info message',
async (version) => {
settingStore = fakeSettingStore(version);
await compareAndLogPostgresVersion(config, settingStore);
expect(errorMessages).toHaveLength(0);
expect(infoMessages).toHaveLength(1);
},
);

View File

@ -1,7 +1,7 @@
import type { ISettingStore, IUnleashConfig } from '../types/index.js';
import semver, { lt, type SemVer } from 'semver';
const MIN_SUPPORTED_POSTGRES_VERSION: SemVer = semver.parse('13.0.0')!;
const MIN_SUPPORTED_POSTGRES_VERSION: SemVer = semver.parse('14.0.0')!;
export async function compareAndLogPostgresVersion(
config: IUnleashConfig,
@ -12,7 +12,7 @@ export async function compareAndLogPostgresVersion(
const pgSemVer = semver.coerce(postgresVersion); // Postgres usually reports Major.Minor, semver needs a patch version included in string
if (pgSemVer !== null && lt(pgSemVer, MIN_SUPPORTED_POSTGRES_VERSION)) {
logger.error(
`You are running an unsupported version of PostgreSQL: ${postgresVersion}. You'll have to upgrade to Postgres 13 or newer to continue getting our support.`,
`You are running an unsupported version of PostgreSQL: ${postgresVersion}. You'll have to upgrade to Postgres 14 or newer to continue getting our support.`,
);
} else {
logger.info(`Running PostgreSQL version ${postgresVersion}.`);

View File

@ -74,7 +74,7 @@ docker run -d \
-e POSTGRES_DB=unleash \
--network unleash \
--name postgres \
postgres:15 # or any 13+ version
postgres:17 # or any 14+ version
```
#### Start Unleash server container