only add admin config if it doesn't exist

This commit is contained in:
Maidul Islam
2024-02-29 17:01:03 -05:00
parent ae4a2089d5
commit 30a1c5ac86

View File

@@ -16,6 +16,12 @@ export async function up(knex: Knex): Promise<void> {
.whereNotNull("id")
.andWhere("id", "<>", ADMIN_CONFIG_UUID)
.limit(1);
const superUserConfigExists = await knex(TableName.SuperAdmin).where("id", ADMIN_CONFIG_UUID).first();
if (!superUserConfigExists) {
await knex(TableName.SuperAdmin).update({ id: ADMIN_CONFIG_UUID }).whereNotNull("id").limit(1);
}
}
export async function down(knex: Knex): Promise<void> {