-
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(subscription-service): add ability to custom plan configuration
add ability to custom plan configuration GH-31
- Loading branch information
1 parent
3453011
commit 9458064
Showing
24 changed files
with
2,586 additions
and
863 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
services/subscription-service/migrations/pg/migrations/20240711124515-add-table-features.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,59 @@ | ||
'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', | ||
'20240711124515-add-features-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', | ||
'20240711124515-add-features-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, | ||
}; |
59 changes: 59 additions & 0 deletions
59
...s/subscription-service/migrations/pg/migrations/20240711130845-add-plan-details-column.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,59 @@ | ||
'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', | ||
'20240711130845-add-plan-details-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) { | ||
var filePath = path.join( | ||
__dirname, | ||
'sqls', | ||
'20240711130845-add-plan-details-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, | ||
}; |
59 changes: 59 additions & 0 deletions
59
...ubscription-service/migrations/pg/migrations/20240715100807-seed-features-and-services.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,59 @@ | ||
'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', | ||
'20240715100807-seed-features-and-services-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', | ||
'20240715100807-seed-features-and-services-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, | ||
}; |
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
1 change: 1 addition & 0 deletions
1
...s/subscription-service/migrations/pg/migrations/sqls/20240711124515-add-features-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.features; |
15 changes: 15 additions & 0 deletions
15
...ces/subscription-service/migrations/pg/migrations/sqls/20240711124515-add-features-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,15 @@ | ||
CREATE TABLE main.features ( | ||
id uuid DEFAULT (md5(((random())::text || (clock_timestamp())::text)))::uuid NOT NULL, | ||
created_on timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
modified_on timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
deleted boolean DEFAULT false NOT NULL, | ||
deleted_on timestamptz, | ||
deleted_by uuid, | ||
created_by uuid NOT NULL, | ||
modified_by uuid, | ||
name varchar(100) NOT NULL, | ||
properties jsonb NOT NULL, | ||
service_id uuid NOT NULL, | ||
CONSTRAINT pk_features_id PRIMARY KEY (id), | ||
CONSTRAINT fk_features_services FOREIGN KEY (service_id) REFERENCES services (id) | ||
); |
2 changes: 2 additions & 0 deletions
2
...ion-service/migrations/pg/migrations/sqls/20240711130845-add-plan-details-column.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,2 @@ | ||
ALTER TABLE main.subscriptions | ||
DROP COLUMN IF EXISTS plan_details; |
2 changes: 2 additions & 0 deletions
2
...ption-service/migrations/pg/migrations/sqls/20240711130845-add-plan-details-column.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,2 @@ | ||
ALTER TABLE main.subscriptions | ||
ADD COLUMN plan_details jsonb NOT NULL; |
2 changes: 2 additions & 0 deletions
2
...-service/migrations/pg/migrations/sqls/20240715100807-seed-features-and-services-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,2 @@ | ||
Delete from main.services; | ||
Delete from main.features; |
46 changes: 46 additions & 0 deletions
46
...on-service/migrations/pg/migrations/sqls/20240715100807-seed-features-and-services-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,46 @@ | ||
INSERT INTO main.services (id, created_on, modified_on, deleted, deleted_on, deleted_by, created_by, modified_by, name) | ||
VALUES ( | ||
'91f3c086-8794-4a62-98a0-7f02d4e8c103', | ||
CURRENT_TIMESTAMP, | ||
CURRENT_TIMESTAMP, | ||
false, | ||
NULL, | ||
NULL, | ||
'123e4567-e89b-12d3-a456-426614174002', | ||
NULL, | ||
'video conferencing service' | ||
); | ||
|
||
INSERT INTO main.features (created_by, name, properties, service_id) | ||
VALUES | ||
( | ||
'123e4567-e89b-12d3-a456-426614174002', | ||
'video call', | ||
'{ | ||
"enabled": true, | ||
"description": "High quality video calling", | ||
"maxParticipants": 100 | ||
}', | ||
'91f3c086-8794-4a62-98a0-7f02d4e8c103' | ||
), | ||
( | ||
'123e4567-e89b-12d3-a456-426614174002', | ||
'chat', | ||
'{ | ||
"enabled": true, | ||
"description": "Real-time text chat", | ||
"property4": "value" | ||
}', | ||
'91f3c086-8794-4a62-98a0-7f02d4e8c103' | ||
), | ||
( | ||
'123e4567-e89b-12d3-a456-426614174002', | ||
'recording', | ||
'{ | ||
"enabled": false, | ||
"description": "Record meetings", | ||
"priority": 3, | ||
"storageLimit": "5GB" | ||
}', | ||
'91f3c086-8794-4a62-98a0-7f02d4e8c103' | ||
); |
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
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
Oops, something went wrong.