mirror of
https://github.com/Infisical/infisical.git
synced 2025-08-05 07:30:33 +00:00
24 lines
1.0 KiB
TypeScript
24 lines
1.0 KiB
TypeScript
import { Knex } from "knex";
|
|
|
|
import { TableName } from "../schemas";
|
|
|
|
export async function up(knex: Knex): Promise<void> {
|
|
const hasEncryptionStrategy = await knex.schema.hasColumn(TableName.KmsServerRootConfig, "encryptionStrategy");
|
|
const hasTimestampsCol = await knex.schema.hasColumn(TableName.KmsServerRootConfig, "createdAt");
|
|
|
|
await knex.schema.alterTable(TableName.KmsServerRootConfig, (t) => {
|
|
if (!hasEncryptionStrategy) t.string("encryptionStrategy").defaultTo("SOFTWARE");
|
|
if (!hasTimestampsCol) t.timestamps(true, true, true);
|
|
});
|
|
}
|
|
|
|
export async function down(knex: Knex): Promise<void> {
|
|
const hasEncryptionStrategy = await knex.schema.hasColumn(TableName.KmsServerRootConfig, "encryptionStrategy");
|
|
const hasTimestampsCol = await knex.schema.hasColumn(TableName.KmsServerRootConfig, "createdAt");
|
|
|
|
await knex.schema.alterTable(TableName.KmsServerRootConfig, (t) => {
|
|
if (hasEncryptionStrategy) t.dropColumn("encryptionStrategy");
|
|
if (hasTimestampsCol) t.dropTimestamps(true);
|
|
});
|
|
}
|