mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-19 11:42:52 +00:00
30 lines
936 B
TypeScript
30 lines
936 B
TypeScript
import { Knex } from "knex";
|
|
|
|
import { TableName } from "@app/db/schemas";
|
|
|
|
export async function up(knex: Knex): Promise<void> {
|
|
// org default role
|
|
if (await knex.schema.hasTable(TableName.Organization)) {
|
|
const hasDefaultRoleCol = await knex.schema.hasColumn(TableName.Organization, "defaultMembershipRole");
|
|
|
|
if (!hasDefaultRoleCol) {
|
|
await knex.schema.alterTable(TableName.Organization, (tb) => {
|
|
tb.string("defaultMembershipRole").notNullable().defaultTo("member");
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
export async function down(knex: Knex): Promise<void> {
|
|
// org default role
|
|
if (await knex.schema.hasTable(TableName.Organization)) {
|
|
const hasDefaultRoleCol = await knex.schema.hasColumn(TableName.Organization, "defaultMembershipRole");
|
|
|
|
if (hasDefaultRoleCol) {
|
|
await knex.schema.alterTable(TableName.Organization, (tb) => {
|
|
tb.dropColumn("defaultMembershipRole");
|
|
});
|
|
}
|
|
}
|
|
}
|