Skip to content

Commit

Permalink
feat: add source column to tenant
Browse files Browse the repository at this point in the history
to store the onboarding source of the tenant such as marketplace, internal etc.
  • Loading branch information
shubhamp-sf committed Oct 14, 2024
1 parent 5e03dcb commit 8fc1295
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
'use strict';

let dbm;
let type;
let seed;
let fs = require('fs');
let path = require('path');
let Promise;

/**
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function (options, seedLink) {
dbm = options.dbmigrate;
type = dbm.dataType;
seed = seedLink;
Promise = options.Promise;
};

exports.up = function (db) {
const filePath = path.join(
__dirname,
'sqls',
'20241009052517-add-tenants-source-column-up.sql',
);
return new Promise(function (resolve, reject) {
fs.readFile(filePath, {encoding: 'utf-8'}, function (err, data) {
if (err) return reject(err);
console.log('received data: ' + data);

resolve(data);
});
}).then(function (data) {
return db.runSql(data);
});
};

exports.down = function (db) {
const filePath = path.join(
__dirname,
'sqls',
'20241009052517-add-tenants-source-column-down.sql',
);
return new Promise(function (resolve, reject) {
fs.readFile(filePath, {encoding: 'utf-8'}, function (err, data) {
if (err) return reject(err);
console.log('received data: ' + data);

resolve(data);
});
}).then(function (data) {
return db.runSql(data);
});
};

exports._meta = {
version: 1,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE main.tenants
DROP COLUMN source;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE main.tenants
ADD COLUMN source varchar(255) DEFAULT 'INTERNAL';
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ export class TenantOnboardDTO extends Model {
})
key: string;

@property({
type: 'string',
description:
'Acquisition source of the tenant. Eg. AWS Marketplace, Super Admin Portal, Registration Page.',
})
source: string;

@property({
required: true,
jsonSchema: {
Expand Down
7 changes: 7 additions & 0 deletions services/tenant-management-service/src/models/tenant.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ export class Tenant extends UserModifiableEntity {
})
key: string;

@property({
type: 'string',
description:
'Acquisition source of the tenant. Eg. AWS Marketplace, Super Admin Portal, Registration Page.',
})
source: string;

@property({
name: 'spoc_user_id',
description:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export class OnboardingService {
domains: dto.domains,
status: TenantStatus.PENDINGPROVISION,
addressId: address?.id,
source: dto.source,
},
{transaction},
);
Expand Down

0 comments on commit 8fc1295

Please sign in to comment.