From 6fe399148d6020b7c398611f7c96ab3325f7ebd2 Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Thu, 7 Sep 2023 10:24:34 -0400 Subject: [PATCH] fix: prefix update --- package.json | 2 +- src/controllers/organization.controller.js | 4 ++-- src/database/migrations/20230824175347-add-prefix.js | 2 +- src/models/organizations/organizations.model.js | 7 ++++++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 12a59ecb..91b87306 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "core-registry-cadt", - "version": "1.6.10", + "version": "1.6.11", "_comment": "DONT CHANGE MAJOR UNLESS DATAMODEL CHANGES: The major version corresponds to the datamodel version your using, so 2.0.0 means it'll use datamodel v2", "private": true, "bin": "build/server.js", diff --git a/src/controllers/organization.controller.js b/src/controllers/organization.controller.js index 69510438..2b7fd47e 100644 --- a/src/controllers/organization.controller.js +++ b/src/controllers/organization.controller.js @@ -23,7 +23,7 @@ export const editHomeOrg = async (req, res) => { await assertWalletIsSynced(); await assertHomeOrgExists(); - const { name } = req.body; + const { name, prefix } = req.body; let icon; @@ -34,7 +34,7 @@ export const editHomeOrg = async (req, res) => { icon = ''; } - Organization.editOrgMeta({ name, icon }); + Organization.editOrgMeta({ name, icon, prefix }); return res.json({ message: 'Home org currently being updated, will be completed soon.', diff --git a/src/database/migrations/20230824175347-add-prefix.js b/src/database/migrations/20230824175347-add-prefix.js index 5cb4c3a1..6493ce1e 100644 --- a/src/database/migrations/20230824175347-add-prefix.js +++ b/src/database/migrations/20230824175347-add-prefix.js @@ -7,7 +7,7 @@ export default { queryInterface.addColumn(table, 'prefix', { type: Sequelize.STRING, allowNull: true, - defaultValue: '{}', + defaultValue: '0', }); }), ); diff --git a/src/models/organizations/organizations.model.js b/src/models/organizations/organizations.model.js index 7d8d2c9b..a81d20d6 100644 --- a/src/models/organizations/organizations.model.js +++ b/src/models/organizations/organizations.model.js @@ -34,6 +34,7 @@ class Organization extends Model { 'fileStoreId', 'registryHash', 'metadata', + 'prefix', ], where: { isHome: true }, raw: true, @@ -427,7 +428,7 @@ class Organization extends Model { } }; - static editOrgMeta = async ({ name, icon }) => { + static editOrgMeta = async ({ name, icon, prefix }) => { const myOrganization = await Organization.getHomeOrg(); const payload = {}; @@ -440,6 +441,10 @@ class Organization extends Model { payload.icon = icon; } + if (prefix) { + payload.prefix = prefix; + } + await datalayer.upsertDataLayer(myOrganization.orgUid, payload); };