Skip to content

feat: add source column to tenant #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading