-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tenant-management): configure user for idp
configure user for idp BREAKING CHANGE: yes g-0
- Loading branch information
1 parent
4a0c7ad
commit 2984ca5
Showing
22 changed files
with
746 additions
and
88 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
...nt-management-service/migrations/pg/migrations/20240925102459-add-table-tenant-configs.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
'use strict'; | ||
|
||
var dbm; | ||
var type; | ||
var seed; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var 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) { | ||
var filePath = path.join(__dirname, 'sqls', '20240925102459-add-table-tenant-configs-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) { | ||
var filePath = path.join(__dirname, 'sqls', '20240925102459-add-table-tenant-configs-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 | ||
}; |
1 change: 1 addition & 0 deletions
1
...nt-service/migrations/pg/migrations/sqls/20240925102459-add-table-tenant-configs-down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
drop table main.tenant_configs; |
33 changes: 33 additions & 0 deletions
33
...ment-service/migrations/pg/migrations/sqls/20240925102459-add-table-tenant-configs-up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
CREATE TABLE IF NOT EXISTS main.tenant_configs | ||
( | ||
id uuid NOT NULL DEFAULT (md5(((random())::text || (clock_timestamp())::text)))::uuid, | ||
config_key varchar(100) NOT NULL, | ||
config_value jsonb NOT NULL, | ||
created_on timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
modified_on timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
created_by uuid, | ||
modified_by uuid, | ||
deleted boolean DEFAULT FALSE NOT NULL, | ||
deleted_by uuid, | ||
deleted_on timestamptz, | ||
tenant_id uuid NOT NULL, | ||
CONSTRAINT pk_tenant_configs_id PRIMARY KEY (id), | ||
CONSTRAINT fk_tenant_configs_tenants FOREIGN KEY (tenant_id) | ||
REFERENCES main.tenants(id) | ||
); | ||
|
||
|
||
CREATE OR REPLACE FUNCTION main.moddatetime() | ||
RETURNS TRIGGER | ||
LANGUAGE plpgsql | ||
AS $function$ | ||
BEGIN | ||
NEW.modified_on = now(); | ||
RETURN NEW; | ||
END; | ||
$function$; | ||
|
||
CREATE TRIGGER mdt_tenant_configs | ||
BEFORE UPDATE ON main.tenant_configs | ||
FOR EACH ROW | ||
EXECUTE FUNCTION main.moddatetime('modified_on'); |
Oops, something went wrong.