From 25a6f99fb9c968ffb4cffc4acd8ac7ed4ef7ed30 Mon Sep 17 00:00:00 2001 From: Nick O'Ferrall Date: Fri, 18 Oct 2024 15:26:39 +0100 Subject: [PATCH 1/4] feat: add featureFlags migration --- .../1729257883498_add-feature-flags.ts | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 packages/server/postgres/migrations/1729257883498_add-feature-flags.ts diff --git a/packages/server/postgres/migrations/1729257883498_add-feature-flags.ts b/packages/server/postgres/migrations/1729257883498_add-feature-flags.ts new file mode 100644 index 00000000000..dfc94403827 --- /dev/null +++ b/packages/server/postgres/migrations/1729257883498_add-feature-flags.ts @@ -0,0 +1,73 @@ +import {Kysely, PostgresDialect} from 'kysely' +import getPg from '../getPg' + +export async function up() { + const pg = new Kysely({ + dialect: new PostgresDialect({ + pool: getPg() + }) + }) + + await pg + .insertInto('FeatureFlag') + .values([ + { + featureName: 'insights', + description: 'Whether the team has access to an AI summary of their wins and challenges', + expiresAt: new Date('2025-01-31T00:00:00.000Z'), + scope: 'Team' + }, + { + featureName: 'noAISummary', + description: 'Disables AI summary feature', + expiresAt: new Date('2074-09-25T15:50:07.656Z'), + scope: 'Organization' + }, + { + featureName: 'publicTeams', + description: 'Whether users can see teams they are not a member of in an org', + expiresAt: new Date('2025-01-31T00:00:00.000Z'), + scope: 'Organization' + }, + { + featureName: 'relatedDiscussions', + description: + 'A comment in a retro discussion thread that uses AI to show similar conversations in the past', + expiresAt: new Date('2025-01-31T00:00:00.000Z'), + scope: 'Organization' + }, + { + featureName: 'standupAISummary', + description: 'Whether the standup UI has an AI meeting Summary or not', + expiresAt: new Date('2025-01-31T00:00:00.000Z'), + scope: 'Organization' + }, + { + featureName: 'suggestGroups', + description: 'Auto-group reflections using AI', + expiresAt: new Date('2025-01-31T00:00:00.000Z'), + scope: 'Organization' + } + ]) + .execute() +} + +export async function down() { + const pg = new Kysely({ + dialect: new PostgresDialect({ + pool: getPg() + }) + }) + + await pg + .deleteFrom('FeatureFlag') + .where('featureName', 'in', [ + 'insights', + 'noAISummary', + 'publicTeams', + 'relatedDiscussions', + 'standupAISummary', + 'suggestGroups' + ]) + .execute() +} From 9ec295e0e3f72e59a19ac65343bd0dd8fcba09b9 Mon Sep 17 00:00:00 2001 From: Nick O'Ferrall Date: Thu, 24 Oct 2024 15:40:21 +0100 Subject: [PATCH 2/4] remove noAISummary from migration --- .../postgres/migrations/1729257883498_add-feature-flags.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/packages/server/postgres/migrations/1729257883498_add-feature-flags.ts b/packages/server/postgres/migrations/1729257883498_add-feature-flags.ts index dfc94403827..4b7a358fc8e 100644 --- a/packages/server/postgres/migrations/1729257883498_add-feature-flags.ts +++ b/packages/server/postgres/migrations/1729257883498_add-feature-flags.ts @@ -17,12 +17,6 @@ export async function up() { expiresAt: new Date('2025-01-31T00:00:00.000Z'), scope: 'Team' }, - { - featureName: 'noAISummary', - description: 'Disables AI summary feature', - expiresAt: new Date('2074-09-25T15:50:07.656Z'), - scope: 'Organization' - }, { featureName: 'publicTeams', description: 'Whether users can see teams they are not a member of in an org', @@ -63,7 +57,6 @@ export async function down() { .deleteFrom('FeatureFlag') .where('featureName', 'in', [ 'insights', - 'noAISummary', 'publicTeams', 'relatedDiscussions', 'standupAISummary', From 884cf924351e793a5afc40e9dd797a711baa6eeb Mon Sep 17 00:00:00 2001 From: Nick O'Ferrall Date: Mon, 28 Oct 2024 15:50:49 +0000 Subject: [PATCH 3/4] use new migration name pattern --- ...ure-flags.ts => 2024-10-28T15:49:33.276Z_add-feature-flags.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename packages/server/postgres/migrations/{1729257883498_add-feature-flags.ts => 2024-10-28T15:49:33.276Z_add-feature-flags.ts} (100%) diff --git a/packages/server/postgres/migrations/1729257883498_add-feature-flags.ts b/packages/server/postgres/migrations/2024-10-28T15:49:33.276Z_add-feature-flags.ts similarity index 100% rename from packages/server/postgres/migrations/1729257883498_add-feature-flags.ts rename to packages/server/postgres/migrations/2024-10-28T15:49:33.276Z_add-feature-flags.ts From 26e52bd2d033cc57577c20542289a3ec7ef481f5 Mon Sep 17 00:00:00 2001 From: Nick O'Ferrall Date: Mon, 28 Oct 2024 17:19:50 +0000 Subject: [PATCH 4/4] update migration to use db from arg --- ...4-10-28T15:49:33.276Z_add-feature-flags.ts | 23 ++++--------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/packages/server/postgres/migrations/2024-10-28T15:49:33.276Z_add-feature-flags.ts b/packages/server/postgres/migrations/2024-10-28T15:49:33.276Z_add-feature-flags.ts index 4b7a358fc8e..7c615d4e587 100644 --- a/packages/server/postgres/migrations/2024-10-28T15:49:33.276Z_add-feature-flags.ts +++ b/packages/server/postgres/migrations/2024-10-28T15:49:33.276Z_add-feature-flags.ts @@ -1,14 +1,7 @@ -import {Kysely, PostgresDialect} from 'kysely' -import getPg from '../getPg' +import {Kysely} from 'kysely' -export async function up() { - const pg = new Kysely({ - dialect: new PostgresDialect({ - pool: getPg() - }) - }) - - await pg +export async function up(db: Kysely): Promise { + await db .insertInto('FeatureFlag') .values([ { @@ -46,14 +39,8 @@ export async function up() { .execute() } -export async function down() { - const pg = new Kysely({ - dialect: new PostgresDialect({ - pool: getPg() - }) - }) - - await pg +export async function down(db: Kysely): Promise { + await db .deleteFrom('FeatureFlag') .where('featureName', 'in', [ 'insights',