diff --git a/src/lib/db/environment-store.ts b/src/lib/db/environment-store.ts index 2aa45a83b4..fcfbf57081 100644 --- a/src/lib/db/environment-store.ts +++ b/src/lib/db/environment-store.ts @@ -10,7 +10,6 @@ import { snakeCaseKeys } from '../util/snakeCase'; interface IEnvironmentsTable { name: string; - display_name: string; created_at?: Date; type: string; sort_order: number; @@ -20,7 +19,6 @@ interface IEnvironmentsTable { const COLUMNS = [ 'type', - 'display_name', 'name', 'created_at', 'sort_order', @@ -31,7 +29,6 @@ const COLUMNS = [ function mapRow(row: IEnvironmentsTable): IEnvironment { return { name: row.name, - displayName: row.display_name, type: row.type, sortOrder: row.sort_order, enabled: row.enabled, @@ -42,7 +39,6 @@ function mapRow(row: IEnvironmentsTable): IEnvironment { function fieldToRow(env: IEnvironment): IEnvironmentsTable { return { name: env.name, - display_name: env.displayName, type: env.type, sort_order: env.sortOrder, enabled: env.enabled, @@ -144,7 +140,7 @@ export default class EnvironmentStore implements IEnvironmentStore { } async update( - env: Pick, + env: Pick, name: string, ): Promise { const updatedEnv = await this.db(TABLE) diff --git a/src/lib/db/feature-strategy-store.ts b/src/lib/db/feature-strategy-store.ts index d64f7c3f11..85e85d2cdc 100644 --- a/src/lib/db/feature-strategy-store.ts +++ b/src/lib/db/feature-strategy-store.ts @@ -213,7 +213,6 @@ class FeatureStrategiesStore implements IFeatureStrategiesStore { 'environments.name as environment_name', 'environments.type as environment_type', 'environments.sort_order as environment_sort_order', - 'environments.display_name as environment_display_name', 'feature_strategies.id as strategy_id', 'feature_strategies.strategy_name as strategy_name', 'feature_strategies.parameters as parameters', @@ -266,7 +265,6 @@ class FeatureStrategiesStore implements IFeatureStrategiesStore { env.enabled = r.enabled; env.type = r.environment_type; env.sortOrder = r.environment_sort_order; - env.displayName = r.environment_display_name; if (!env.strategies) { env.strategies = []; } @@ -300,7 +298,6 @@ class FeatureStrategiesStore implements IFeatureStrategiesStore { private getEnvironment(r: any): IEnvironmentOverview { return { name: r.environment, - displayName: r.display_name, enabled: r.enabled, type: r.environment_type, sortOrder: r.environment_sort_order, @@ -321,7 +318,6 @@ class FeatureStrategiesStore implements IFeatureStrategiesStore { 'features.stale as stale', 'feature_environments.enabled as enabled', 'feature_environments.environment as environment', - 'environments.display_name as display_name', 'environments.type as environment_type', 'environments.sort_order as environment_sort_order', ) diff --git a/src/lib/services/state-service.test.ts b/src/lib/services/state-service.test.ts index de6ac3496c..8cba518de4 100644 --- a/src/lib/services/state-service.test.ts +++ b/src/lib/services/state-service.test.ts @@ -533,12 +533,10 @@ test('exporting to new format works', async () => { }); await stores.environmentStore.create({ name: 'dev', - displayName: 'Development', type: 'development', }); await stores.environmentStore.create({ name: 'prod', - displayName: 'Production', type: 'production', }); await stores.featureToggleStore.create('fancy', { @@ -575,12 +573,10 @@ test('featureStrategies can keep existing', async () => { }); await stores.environmentStore.create({ name: 'dev', - displayName: 'Development', type: 'development', }); await stores.environmentStore.create({ name: 'prod', - displayName: 'Production', type: 'production', }); await stores.featureToggleStore.create('fancy', { @@ -623,12 +619,10 @@ test('featureStrategies should not keep existing if dropBeforeImport', async () }); await stores.environmentStore.create({ name: 'dev', - displayName: 'Development', type: 'development', }); await stores.environmentStore.create({ name: 'prod', - displayName: 'Production', type: 'production', }); await stores.featureToggleStore.create('fancy', { diff --git a/src/lib/types/model.ts b/src/lib/types/model.ts index 34c1b4c661..f0eb7ad509 100644 --- a/src/lib/types/model.ts +++ b/src/lib/types/model.ts @@ -103,7 +103,6 @@ export interface IVariant { export interface IEnvironment { name: string; - displayName: string; type: string; sortOrder: number; enabled: boolean; @@ -112,14 +111,12 @@ export interface IEnvironment { export interface IEnvironmentCreate { name: string; - displayName: string; type: string; sortOrder?: number; } export interface IEnvironmentOverview { name: string; - displayName: string; enabled: boolean; type: string; sortOrder: number; diff --git a/src/lib/types/stores/environment-store.ts b/src/lib/types/stores/environment-store.ts index cfc4ba609a..c975ad28a4 100644 --- a/src/lib/types/stores/environment-store.ts +++ b/src/lib/types/stores/environment-store.ts @@ -5,7 +5,7 @@ export interface IEnvironmentStore extends Store { exists(name: string): Promise; create(env: IEnvironmentCreate): Promise; update( - env: Pick, + env: Pick, name: string, ): Promise; updateProperty( diff --git a/src/migrations/20210928065411-remove-displayname-from-environments.js b/src/migrations/20210928065411-remove-displayname-from-environments.js new file mode 100644 index 0000000000..ad7360c27a --- /dev/null +++ b/src/migrations/20210928065411-remove-displayname-from-environments.js @@ -0,0 +1,17 @@ +'use strict'; + +exports.up = function (db, cb) { + db.runSql( + `ALTER TABLE environments + DROP COLUMN display_name`, + cb, + ); +}; + +exports.down = function (db, cb) { + db.runSql( + `ALTER TABLE environments + ADD COLUMN display_name TEXT`, + cb, + ); +}; diff --git a/src/test/e2e/api/admin/environment.test.ts b/src/test/e2e/api/admin/environment.test.ts index 8296208f2d..840396bb46 100644 --- a/src/test/e2e/api/admin/environment.test.ts +++ b/src/test/e2e/api/admin/environment.test.ts @@ -24,7 +24,6 @@ test('Can list all existing environments', async () => { .expect((res) => { expect(res.body.version).toBe(1); expect(res.body.environments[0]).toStrictEqual({ - displayName: 'Default Environment', name: DEFAULT_ENV, enabled: true, sortOrder: 1, @@ -38,7 +37,6 @@ test('Can update sort order', async () => { const envName = 'update-sort-order'; await db.stores.environmentStore.create({ name: envName, - displayName: 'Enable feature for environment', type: 'production', }); await app.request @@ -81,7 +79,6 @@ test('Can update environment enabled status', async () => { const envName = 'enable-environment'; await db.stores.environmentStore.create({ name: envName, - displayName: 'Enable feature for environment', type: 'production', }); await app.request @@ -95,7 +92,6 @@ test('Can update environment disabled status', async () => { await db.stores.environmentStore.create({ name: envName, - displayName: 'Enable feature for environment', type: 'production', }); @@ -128,7 +124,6 @@ test('Can get specific environment', async () => { await db.stores.environmentStore.create({ name: envName, type: 'production', - displayName: 'Fun!', }); await app.request .get(`/api/admin/environments/${envName}`) diff --git a/src/test/e2e/api/admin/project/environments.e2e.test.ts b/src/test/e2e/api/admin/project/environments.e2e.test.ts index 06907d29b8..1aead68270 100644 --- a/src/test/e2e/api/admin/project/environments.e2e.test.ts +++ b/src/test/e2e/api/admin/project/environments.e2e.test.ts @@ -36,7 +36,6 @@ test('Should add environment to project', async () => { // Endpoint to create env does not exists anymore await db.stores.environmentStore.create({ name: 'test', - displayName: 'Test Env', type: 'test', }); await app.request @@ -67,7 +66,6 @@ test('Should remove environment from project', async () => { await db.stores.environmentStore.create({ name, - displayName: 'Test Env', type: 'test', }); diff --git a/src/test/e2e/api/admin/project/feature.strategy.e2e.test.ts b/src/test/e2e/api/admin/project/feature.strategy.e2e.test.ts index aed55e9253..9a39c57fae 100644 --- a/src/test/e2e/api/admin/project/feature.strategy.e2e.test.ts +++ b/src/test/e2e/api/admin/project/feature.strategy.e2e.test.ts @@ -174,7 +174,6 @@ test('Project overview includes environment connected to feature', async () => { }); await db.stores.environmentStore.create({ name: 'project-overview', - displayName: 'Project Overview', type: 'production', }); await app.request @@ -208,7 +207,6 @@ test('Disconnecting environment from project, removes environment from features }); await db.stores.environmentStore.create({ name: 'dis-project-overview', - displayName: 'Project Overview', type: 'production', }); await app.request @@ -236,7 +234,6 @@ test('Can enable/disable environment for feature with strategies', async () => { // Create environment await db.stores.environmentStore.create({ name: envName, - displayName: 'Enable feature for environment', type: 'production', }); // Connect environment to project @@ -386,7 +383,6 @@ test('Can get environment info for feature toggle', async () => { // Create environment await db.stores.environmentStore.create({ name: envName, - displayName: 'Enable feature for environment', type: 'production', }); // Connect environment to project @@ -550,7 +546,6 @@ test('Can add strategy to feature toggle to a "some-env-2"', async () => { // Create environment await db.stores.environmentStore.create({ name: envName, - displayName: 'Enable feature for environment', type: 'production', }); // Connect environment to project @@ -591,13 +586,11 @@ test('Environments are returned in sortOrder', async () => { // Create environments await db.stores.environmentStore.create({ name: sortedLast, - displayName: 'Enable feature for environment', type: 'production', sortOrder: 8000, }); await db.stores.environmentStore.create({ name: sortedSecond, - displayName: 'Enable feature for environment', type: 'production', sortOrder: 8, }); @@ -659,7 +652,6 @@ test('Can get strategies for feature and environment', async () => { // Create environment await db.stores.environmentStore.create({ name: envName, - displayName: 'Enable feature for environment', type: 'production', }); // Connect environment to project @@ -714,7 +706,6 @@ test('Can update a strategy based on id', async () => { // Create environment await db.stores.environmentStore.create({ name: envName, - displayName: 'Enable feature for environment', type: 'production', }); // Connect environment to project @@ -767,7 +758,6 @@ test('Trying to update a non existing feature strategy should yield 404', async // Create environment await db.stores.environmentStore.create({ name: envName, - displayName: 'Enable feature for environment', type: 'production', }); // Connect environment to project @@ -798,7 +788,6 @@ test('Can patch a strategy based on id', async () => { // Create environment await db.stores.environmentStore.create({ name: envName, - displayName: 'Enable feature for environment', type: 'test', }); // Connect environment to project @@ -851,7 +840,6 @@ test('Trying to get a non existing feature strategy should yield 404', async () // Create environment await db.stores.environmentStore.create({ name: envName, - displayName: 'Enable feature for environment', type: 'production', }); // Connect environment to project @@ -880,7 +868,6 @@ test('Can not enable environment for feature without strategies', async () => { // Create environment await db.stores.environmentStore.create({ name: environment, - displayName: 'Enable feature for environment', type: 'test', }); // Connect environment to project @@ -922,7 +909,6 @@ test('Enabling environment creates a FEATURE_ENVIRONMENT_ENABLED event', async ( // Create environment await db.stores.environmentStore.create({ name: environment, - displayName: 'Enable feature for environment', type: 'test', }); // Connect environment to project @@ -965,7 +951,6 @@ test('Disabling environment creates a FEATURE_ENVIRONMENT_DISABLED event', async // Create environment await db.stores.environmentStore.create({ name: environment, - displayName: 'Enable feature for environment', type: 'test', }); // Connect environment to project @@ -1009,7 +994,6 @@ test('Can delete strategy from feature toggle', async () => { // Create environment await db.stores.environmentStore.create({ name: envName, - displayName: 'Enable feature for environment', type: 'test', }); // Connect environment to project @@ -1053,7 +1037,6 @@ test('List of strategies should respect sortOrder', async () => { // Create environment await db.stores.environmentStore.create({ name: envName, - displayName: 'Enable feature for environment', type: 'test', }); // Connect environment to project @@ -1084,12 +1067,10 @@ test('Feature strategies list should respect strategy sortorders for each enviro // Create environment await db.stores.environmentStore.create({ name: envName, - displayName: 'Sort orders within environment', type: 'test', }); await db.stores.environmentStore.create({ name: secondEnv, - displayName: 'Sort orders within environment', type: 'test', }); // Connect environment to project diff --git a/src/test/e2e/api/admin/state.e2e.test.ts b/src/test/e2e/api/admin/state.e2e.test.ts index fc8b450b46..6d9e7d49fa 100644 --- a/src/test/e2e/api/admin/state.e2e.test.ts +++ b/src/test/e2e/api/admin/state.e2e.test.ts @@ -142,7 +142,6 @@ test('Can roundtrip. I.e. export and then import', async () => { await db.stores.environmentStore.create({ name: environmentId, type: 'test', - displayName: 'Environment for export', }); await db.stores.projectStore.create({ name: projectId, @@ -191,7 +190,6 @@ test('Roundtrip with tags works', async () => { await db.stores.environmentStore.create({ name: environmentId, type: 'test', - displayName: 'Environment for export', }); await db.stores.projectStore.create({ name: projectId, @@ -253,7 +251,6 @@ test('Roundtrip with strategies in multiple environments works', async () => { await db.stores.environmentStore.create({ name: environmentId, type: 'test', - displayName: 'Environment for export', }); await db.stores.projectStore.create({ name: projectId, diff --git a/src/test/e2e/api/client/feature.e2e.test.ts b/src/test/e2e/api/client/feature.e2e.test.ts index e0e73f852d..7625ebaa07 100644 --- a/src/test/e2e/api/client/feature.e2e.test.ts +++ b/src/test/e2e/api/client/feature.e2e.test.ts @@ -176,7 +176,6 @@ test('Can get strategies for specific environment', async () => { await db.stores.environmentStore.create({ name: 'testing', - displayName: 'simple test', type: 'test', }); diff --git a/src/test/e2e/api/client/feature.token.access.e2e.test.ts b/src/test/e2e/api/client/feature.token.access.e2e.test.ts index 0b394bc5a4..8e45a957b1 100644 --- a/src/test/e2e/api/client/feature.token.access.e2e.test.ts +++ b/src/test/e2e/api/client/feature.token.access.e2e.test.ts @@ -28,7 +28,6 @@ beforeAll(async () => { await environmentStore.create({ name: environment, - displayName: '', type: 'test', }); diff --git a/src/test/e2e/api/client/metrics.e2e.access.e2e.test.ts b/src/test/e2e/api/client/metrics.e2e.access.e2e.test.ts index d2b12b0d57..a85a73b608 100644 --- a/src/test/e2e/api/client/metrics.e2e.access.e2e.test.ts +++ b/src/test/e2e/api/client/metrics.e2e.access.e2e.test.ts @@ -23,7 +23,6 @@ test('should enrich metrics with environment from api-token', async () => { await environmentStore.create({ name: 'some', - displayName: '', type: 'test', }); diff --git a/src/test/e2e/helpers/database.json b/src/test/e2e/helpers/database.json index f5d4b3d7e9..fc6ea665fc 100644 --- a/src/test/e2e/helpers/database.json +++ b/src/test/e2e/helpers/database.json @@ -30,7 +30,6 @@ "environments": [ { "name": "default", - "displayName": "Default Environment", "type": "production", "sortOrder": 1, "enabled": true, diff --git a/src/test/e2e/services/environment-service.test.ts b/src/test/e2e/services/environment-service.test.ts index ac97dca4fd..1d7b486e4e 100644 --- a/src/test/e2e/services/environment-service.test.ts +++ b/src/test/e2e/services/environment-service.test.ts @@ -22,7 +22,6 @@ afterAll(async () => { test('Can get environment', async () => { const created = await db.stores.environmentStore.create({ name: 'testenv', - displayName: 'Environment for testing', type: 'production', }); @@ -33,7 +32,6 @@ test('Can get environment', async () => { test('Can get all', async () => { await db.stores.environmentStore.create({ name: 'testenv2', - displayName: 'Environment for testing', type: 'production', }); @@ -44,7 +42,6 @@ test('Can get all', async () => { test('Can connect environment to project', async () => { await db.stores.environmentStore.create({ name: 'test-connection', - displayName: '', type: 'production', }); await stores.featureToggleStore.create('default', { @@ -63,7 +60,6 @@ test('Can connect environment to project', async () => { expect(f.environments).toEqual([ { name: 'test-connection', - displayName: '', enabled: false, sortOrder: 9999, type: 'production', @@ -75,7 +71,6 @@ test('Can connect environment to project', async () => { test('Can remove environment from project', async () => { await db.stores.environmentStore.create({ name: 'removal-test', - displayName: '', type: 'production', }); await stores.featureToggleStore.create('default', { @@ -92,7 +87,6 @@ test('Can remove environment from project', async () => { expect(f.environments).toEqual([ { name: 'removal-test', - displayName: '', enabled: false, sortOrder: 9999, type: 'production', @@ -113,7 +107,6 @@ test('Can remove environment from project', async () => { test('Adding same environment twice should throw a NameExistsError', async () => { await db.stores.environmentStore.create({ name: 'uniqueness-test', - displayName: '', type: 'production', }); await service.removeEnvironmentFromProject('test-connection', 'default'); diff --git a/src/test/e2e/stores/project-store.e2e.test.ts b/src/test/e2e/stores/project-store.e2e.test.ts index aed8b4e7c3..48d2a8f7d9 100644 --- a/src/test/e2e/stores/project-store.e2e.test.ts +++ b/src/test/e2e/stores/project-store.e2e.test.ts @@ -123,7 +123,6 @@ test('should add environment to project', async () => { await environmentStore.create({ name: 'test', - displayName: 'Test Env', type: 'production', }); diff --git a/src/test/fixtures/fake-environment-store.ts b/src/test/fixtures/fake-environment-store.ts index a939f5ec30..c7aaad3127 100644 --- a/src/test/fixtures/fake-environment-store.ts +++ b/src/test/fixtures/fake-environment-store.ts @@ -37,7 +37,7 @@ export default class FakeEnvironmentStore implements IEnvironmentStore { } async update( - env: Pick, + env: Pick, name: string, ): Promise { const found = this.environments.find(