mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-19 20:11:35 +00:00
feat: switched to root org id pattern
This commit is contained in:
@@ -6,8 +6,12 @@ export async function up(knex: Knex): Promise<void> {
|
||||
const hasParentOrgId = await knex.schema.hasColumn(TableName.Organization, "parentOrgId");
|
||||
if (!hasParentOrgId) {
|
||||
await knex.schema.alterTable(TableName.Organization, (t) => {
|
||||
// the one just above the chain
|
||||
t.uuid("parentOrgId");
|
||||
t.foreign("parentOrgId").references("id").inTable(TableName.Organization).onDelete("CASCADE");
|
||||
// this would root organization containing various informations like billing etc
|
||||
t.uuid("rootOrgId");
|
||||
t.foreign("rootOrgId").references("id").inTable(TableName.Organization).onDelete("CASCADE");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -22,9 +26,11 @@ export async function up(knex: Knex): Promise<void> {
|
||||
|
||||
export async function down(knex: Knex): Promise<void> {
|
||||
const hasParentOrgId = await knex.schema.hasColumn(TableName.Organization, "parentOrgId");
|
||||
if (hasParentOrgId) {
|
||||
const hasRootOrgId = await knex.schema.hasColumn(TableName.Organization, "rootOrgId");
|
||||
if (hasParentOrgId || hasRootOrgId) {
|
||||
await knex.schema.alterTable(TableName.Organization, (t) => {
|
||||
t.dropColumn("parentOrgId");
|
||||
if (hasParentOrgId) t.dropColumn("parentOrgId");
|
||||
if (hasRootOrgId) t.dropColumn("rootOrgId");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user