mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
misc: separate migration steps for remvoing fk and orphaned identities
This commit is contained in:
@@ -38,11 +38,6 @@ export async function up(knex: Knex): Promise<void> {
|
||||
.merge();
|
||||
}
|
||||
}
|
||||
|
||||
await tx(TableName.Identity).whereNull("orgId").delete();
|
||||
await tx.schema.alterTable(TableName.Identity, (t) => {
|
||||
t.uuid("orgId").notNullable().alter();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import { Knex } from "knex";
|
||||
|
||||
import { TableName } from "../schemas";
|
||||
|
||||
export async function up(knex: Knex): Promise<void> {
|
||||
await knex.transaction(async (tx) => {
|
||||
await tx.schema.alterTable(TableName.IdentityAccessToken, (table) => {
|
||||
table.dropForeign("identityId");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export async function down(knex: Knex): Promise<void> {
|
||||
await knex.transaction(async (tx) => {
|
||||
await tx.schema.alterTable(TableName.IdentityAccessToken, (table) => {
|
||||
table.foreign("identityId").references("id").inTable(TableName.Identity);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const config = { transaction: false };
|
||||
export { config };
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Knex } from "knex";
|
||||
|
||||
import { TableName } from "../schemas";
|
||||
|
||||
export async function up(knex: Knex): Promise<void> {
|
||||
await knex.transaction(async (tx) => {
|
||||
const hasIdentityOrgCol = await tx.schema.hasColumn(TableName.Identity, "orgId");
|
||||
if (hasIdentityOrgCol) {
|
||||
await tx(TableName.Identity).whereNull("orgId").delete();
|
||||
await tx.schema.alterTable(TableName.Identity, (t) => {
|
||||
t.uuid("orgId").notNullable().alter();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export async function down(): Promise<void> {}
|
||||
|
||||
const config = { transaction: false };
|
||||
export { config };
|
||||
Reference in New Issue
Block a user