review fixes

This commit is contained in:
x032205
2025-05-13 10:44:28 -04:00
parent 4b94848a79
commit d483e70748
2 changed files with 11 additions and 11 deletions
@@ -6,22 +6,20 @@ export async function up(knex: Knex): Promise<void> {
if (await knex.schema.hasTable(TableName.Certificate)) { if (await knex.schema.hasTable(TableName.Certificate)) {
const hasProjectIdColumn = await knex.schema.hasColumn(TableName.Certificate, "projectId"); const hasProjectIdColumn = await knex.schema.hasColumn(TableName.Certificate, "projectId");
if (!hasProjectIdColumn) { if (!hasProjectIdColumn) {
await knex.transaction(async (trx) => { await knex.schema.alterTable(TableName.Certificate, (t) => {
await trx.schema.alterTable(TableName.Certificate, (t) => { t.string("projectId", 36).nullable();
t.string("projectId", 36).nullable(); t.foreign("projectId").references("id").inTable(TableName.Project).onDelete("CASCADE");
t.foreign("projectId").references("id").inTable(TableName.Project).onDelete("CASCADE"); });
});
await trx.raw(` await knex.raw(`
UPDATE "${TableName.Certificate}" cert UPDATE "${TableName.Certificate}" cert
SET "projectId" = ca."projectId" SET "projectId" = ca."projectId"
FROM "${TableName.CertificateAuthority}" ca FROM "${TableName.CertificateAuthority}" ca
WHERE cert."caId" = ca.id WHERE cert."caId" = ca.id
`); `);
await trx.schema.alterTable(TableName.Certificate, (t) => { await knex.schema.alterTable(TableName.Certificate, (t) => {
t.string("projectId").notNullable().alter(); t.string("projectId").notNullable().alter();
});
}); });
} }
@@ -449,7 +449,8 @@ export const pkiSubscriberServiceFactory = ({
notBefore: notBeforeDate, notBefore: notBeforeDate,
notAfter: notAfterDate, notAfter: notAfterDate,
keyUsages: selectedKeyUsages, keyUsages: selectedKeyUsages,
extendedKeyUsages: subscriber.extendedKeyUsages as CertExtendedKeyUsage[] extendedKeyUsages: subscriber.extendedKeyUsages as CertExtendedKeyUsage[],
projectId
}, },
tx tx
); );
@@ -718,7 +719,8 @@ export const pkiSubscriberServiceFactory = ({
notBefore: notBeforeDate, notBefore: notBeforeDate,
notAfter: notAfterDate, notAfter: notAfterDate,
keyUsages: selectedKeyUsages, keyUsages: selectedKeyUsages,
extendedKeyUsages: selectedExtendedKeyUsages extendedKeyUsages: selectedExtendedKeyUsages,
projectId
}, },
tx tx
); );