1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-05 17:53:12 +02:00

Revert "Add changeRequestEnabled to project and project_environments (#2357)"

This reverts commit 47a617c78b.
This commit is contained in:
andreas-unleash 2022-11-10 11:20:38 +02:00 committed by GitHub
parent 0649262c70
commit a908c85e7b
8 changed files with 5 additions and 75 deletions

View File

@ -21,14 +21,12 @@ const COLUMNS = [
'created_at',
'health',
'updated_at',
'change_request_enabled',
];
const TABLE = 'projects';
export interface IEnvironmentProjectLink {
environmentName: string;
projectId: string;
changeRequestsEnabled?: string;
}
export interface IProjectMembersCount {
@ -80,7 +78,7 @@ class ProjectStore implements IProjectStore {
let projects = this.db(TABLE)
.select(
this.db.raw(
'projects.id, projects.name, projects.description, projects.health, projects.updated_at, projects.change_request_enabled, count(features.name) AS number_of_features',
'projects.id, projects.name, projects.description, projects.health, projects.updated_at, count(features.name) AS number_of_features',
),
)
.leftJoin('features', 'features.project', 'projects.id')
@ -117,7 +115,6 @@ class ProjectStore implements IProjectStore {
featureCount: Number(row.number_of_features) || 0,
memberCount: Number(row.number_of_users) || 0,
updatedAt: row.updated_at,
changeRequestsEnabled: row.change_request_enabled || false,
};
}
@ -199,7 +196,6 @@ class ProjectStore implements IProjectStore {
const environments = projects.map((p) => ({
project_id: p.id,
environment_name: DEFAULT_ENV,
change_request_enabled: p.change_request_enabled,
}));
await this.db('project_environments')
.insert(environments)
@ -244,13 +240,8 @@ class ProjectStore implements IProjectStore {
id: string,
environment: string,
): Promise<void> {
const project = await this.get(id);
await this.db('project_environments')
.insert({
project_id: id,
environment_name: environment,
change_request_enabled: project.changeRequestsEnabled,
})
.insert({ project_id: id, environment_name: environment })
.onConflict(['project_id', 'environment_name'])
.ignore();
}
@ -259,12 +250,10 @@ class ProjectStore implements IProjectStore {
environment: string,
projects: string[],
): Promise<void> {
const rows = projects.map(async (projectId) => {
const project = await this.get(projectId);
const rows = projects.map((project) => {
return {
project_id: projectId,
project_id: project,
environment_name: environment,
change_request_enabled: project.changeRequestsEnabled || false,
};
});
@ -381,7 +370,6 @@ class ProjectStore implements IProjectStore {
return {
environmentName: row.environment_name,
projectId: row.project_id,
changeRequestsEnabled: row.change_request_enabled,
};
}
@ -398,7 +386,6 @@ class ProjectStore implements IProjectStore {
createdAt: row.created_at,
health: row.health || 100,
updatedAt: row.updated_at || new Date(),
changeRequestsEnabled: row.change_request_enabled || false,
};
}
}

View File

@ -9,9 +9,6 @@ export const projectEnvironmentSchema = {
environment: {
type: 'string',
},
changeRequestsEnabled: {
type: 'boolean',
},
},
components: {},
} as const;

View File

@ -10,22 +10,6 @@ test('projectSchema', () => {
featureCount: 10,
memberCount: 3,
updatedAt: '2022-06-28T17:33:53.963Z',
changeRequestsEnabled: false,
};
expect(
validateSchema('#/components/schemas/projectSchema', {}),
).not.toBeUndefined();
expect(
validateSchema('#/components/schemas/projectSchema', data),
).toBeUndefined();
});
test('projectSchema with only required', () => {
const data: ProjectSchema = {
name: 'Default',
id: 'default',
};
expect(

View File

@ -33,9 +33,6 @@ export const projectSchema = {
format: 'date-time',
nullable: true,
},
changeRequestsEnabled: {
type: 'boolean',
},
},
components: {},
} as const;

View File

@ -345,8 +345,8 @@ export interface IProject {
health?: number;
createdAt?: Date;
updatedAt?: Date;
changeRequestsEnabled?: boolean;
}
export interface ICustomRole {
id: number;
name: string;

View File

@ -10,7 +10,6 @@ export interface IProjectInsert {
name: string;
description: string;
updatedAt?: Date;
changeRequestsEnabled?: boolean;
}
export interface IProjectArchived {
@ -27,11 +26,6 @@ export interface IProjectQuery {
id?: string;
}
export interface IProjectEnvironmentWithChangeRequests {
environment: string;
changeRequestsEnabled: boolean;
}
export interface IProjectStore extends Store<IProject, string> {
hasProject(id: string): Promise<boolean>;
updateHealth(healthUpdate: IProjectHealthUpdate): Promise<void>;
@ -50,11 +44,9 @@ export interface IProjectStore extends Store<IProject, string> {
getProjectsWithCounts(query?: IProjectQuery): Promise<IProjectWithCount[]>;
count(): Promise<number>;
getAll(query?: IProjectQuery): Promise<IProject[]>;
getProjectLinksForEnvironments(
environments: string[],
): Promise<IEnvironmentProjectLink[]>;
addEnvironmentToProjects(
environment: string,
projects: string[],

View File

@ -1,21 +0,0 @@
'use strict';
exports.up = function (db, callback) {
db.runSql(
`
ALTER TABLE project_environments add column if not exists change_request_enabled bool default false;
ALTER TABLE projects add column if not exists change_request_enabled bool default false;
`,
callback,
);
};
exports.down = function (db, callback) {
db.runSql(
`
ALTER TABLE project_environments drop column if exists change_request_enabled;
ALTER TABLE projects drop column if exists change_request_enabled;
`,
callback,
);
};

View File

@ -2255,9 +2255,6 @@ exports[`should serve the OpenAPI spec 1`] = `
"projectEnvironmentSchema": {
"additionalProperties": false,
"properties": {
"changeRequestsEnabled": {
"type": "boolean",
},
"environment": {
"type": "string",
},
@ -2270,9 +2267,6 @@ exports[`should serve the OpenAPI spec 1`] = `
"projectSchema": {
"additionalProperties": false,
"properties": {
"changeRequestsEnabled": {
"type": "boolean",
},
"createdAt": {
"format": "date-time",
"type": "string",