mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 10:28:00 +00:00
Improve code quality
This commit is contained in:
@@ -3,49 +3,22 @@ import { Knex } from "knex";
|
|||||||
import { TableName } from "@app/db/schemas";
|
import { TableName } from "@app/db/schemas";
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
export async function up(knex: Knex): Promise<void> {
|
||||||
const hasSecretVersionV2UserActorId = await knex.schema.hasColumn(TableName.SecretVersionV2, "userActorId");
|
if (!(await knex.schema.hasColumn(TableName.SecretVersionV2, "userActorId"))) {
|
||||||
const hasSecretVersionV2IdentityActorId = await knex.schema.hasColumn(TableName.SecretVersionV2, "identityActorId");
|
|
||||||
const hasSecretVersionV2ActorType = await knex.schema.hasColumn(TableName.SecretVersionV2, "actorType");
|
|
||||||
|
|
||||||
if (!hasSecretVersionV2UserActorId) {
|
|
||||||
await knex.schema.alterTable(TableName.SecretVersionV2, (t) => {
|
await knex.schema.alterTable(TableName.SecretVersionV2, (t) => {
|
||||||
t.uuid("userActorId");
|
t.uuid("userActorId");
|
||||||
t.foreign("userActorId").references("id").inTable(TableName.Users);
|
t.foreign("userActorId").references("id").inTable(TableName.Users);
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hasSecretVersionV2IdentityActorId) {
|
|
||||||
await knex.schema.alterTable(TableName.SecretVersionV2, (t) => {
|
|
||||||
t.uuid("identityActorId");
|
t.uuid("identityActorId");
|
||||||
t.foreign("identityActorId").references("id").inTable(TableName.Identity);
|
t.foreign("identityActorId").references("id").inTable(TableName.Identity);
|
||||||
});
|
|
||||||
}
|
|
||||||
if (!hasSecretVersionV2ActorType) {
|
|
||||||
await knex.schema.alterTable(TableName.SecretVersionV2, (t) => {
|
|
||||||
t.string("actorType");
|
t.string("actorType");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex: Knex): Promise<void> {
|
||||||
const hasSecretVersionV2UserActorId = await knex.schema.hasColumn(TableName.SecretVersionV2, "userActorId");
|
if (await knex.schema.hasColumn(TableName.SecretVersionV2, "userActorId")) {
|
||||||
const hasSecretVersionV2IdentityActorId = await knex.schema.hasColumn(TableName.SecretVersionV2, "identityActorId");
|
|
||||||
const hasSecretVersionV2ActorType = await knex.schema.hasColumn(TableName.SecretVersionV2, "actorType");
|
|
||||||
|
|
||||||
if (hasSecretVersionV2UserActorId) {
|
|
||||||
await knex.schema.alterTable(TableName.SecretVersionV2, (t) => {
|
await knex.schema.alterTable(TableName.SecretVersionV2, (t) => {
|
||||||
t.dropColumn("userActorId");
|
t.dropColumn("userActorId");
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasSecretVersionV2IdentityActorId) {
|
|
||||||
await knex.schema.alterTable(TableName.SecretVersionV2, (t) => {
|
|
||||||
t.dropColumn("identityActorId");
|
t.dropColumn("identityActorId");
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasSecretVersionV2ActorType) {
|
|
||||||
await knex.schema.alterTable(TableName.SecretVersionV2, (t) => {
|
|
||||||
t.dropColumn("actorType");
|
t.dropColumn("actorType");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -380,6 +380,7 @@ export const secretSnapshotServiceFactory = ({
|
|||||||
envId,
|
envId,
|
||||||
id,
|
id,
|
||||||
tags,
|
tags,
|
||||||
|
// exclude the bottom fields from the secret - they are for versioning only.
|
||||||
userActorId,
|
userActorId,
|
||||||
identityActorId,
|
identityActorId,
|
||||||
actorType,
|
actorType,
|
||||||
|
|||||||
Reference in New Issue
Block a user