Skip to content

Commit

Permalink
chore: fix stored enum for source_type for deployment and task
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed Oct 29, 2024
1 parent 961286f commit 56f170f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
exports.up = function(knex) {
// fix the way the enum values are stored to be lowercase for mysql strict
return Promise.all([
knex('deployment')
.where('source_type', '=', 'API')
.update('source_type', 'api'),
knex('deployment')
.where('source_type', '=', 'WEBHOOK')
.update('source_type', 'webhook'),
knex('task')
.where('source_type', '=', 'API')
.update('source_type', 'api'),
]);
};

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.down = function(knex) {
return knex.schema;
};
2 changes: 1 addition & 1 deletion services/api/src/models/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface Environment {
openshiftProjectName?: string; // varchar(100) COLLATE utf8_bin DEFAULT NULL,
updated?: string; // timestamp NOT NULL DEFAULT current_timestamp(),
created?: string; // timestamp NOT NULL DEFAULT current_timestamp(),
deleted?: string; // timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
deleted?: string;
route?: string; // varchar(300) COLLATE utf8_bin DEFAULT NULL,
routes?: string; // text COLLATE utf8_bin DEFAULT NULL,
autoIdle?: Boolean; // int(1) NOT NULL DEFAULT 1,
Expand Down
3 changes: 3 additions & 0 deletions services/api/src/resources/deployment/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,9 @@ export const addDeployment: ResolverFn = async (
if (!sourceType) {
sourceType = "API"
}
if (sourceType) {
sourceType.toLocaleLowerCase();
}
const { insertId } = await query(
sqlClientPool,
Sql.insertDeployment({
Expand Down
3 changes: 3 additions & 0 deletions services/api/src/resources/task/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ export const Helpers = (sqlClientPool: Pool, hasPermission, adminScopes) => {
sourceUser: string;
sourceType: string;
}) => {
if (sourceType) {
sourceType.toLocaleLowerCase();
}
const { insertId } = await query(
sqlClientPool,
Sql.insertTask({
Expand Down

0 comments on commit 56f170f

Please sign in to comment.