-
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 billing functionality to subscription…
… service add billing functionality to subscription service BREAKING CHANGE: yes gh-34
- Loading branch information
1 parent
4e6356a
commit 004c267
Showing
23 changed files
with
1,123 additions
and
134 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.
59 changes: 59 additions & 0 deletions
59
services/subscription-service/migrations/pg/migrations/20240209122448-add-customer-table.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'; | ||
|
||
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) { | ||
let filePath = path.join( | ||
__dirname, | ||
'sqls', | ||
'20240209122448-add-customer-table-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) { | ||
let filePath = path.join( | ||
__dirname, | ||
'sqls', | ||
'20240209122448-add-customer-table-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
...cription-service/migrations/pg/migrations/sqls/20240209122448-add-customer-table-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.billing_customer; |
14 changes: 14 additions & 0 deletions
14
...bscription-service/migrations/pg/migrations/sqls/20240209122448-add-customer-table-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,14 @@ | ||
CREATE TABLE main.billing_customer ( | ||
id uuid DEFAULT (md5(((random())::text || (clock_timestamp())::text)))::uuid NOT NULL , tenant_id uuid NOT NULL , | ||
customer_id VARCHAR(255) NOT NULL, | ||
payment_source_id VARCHAR(255), | ||
invoice_id VARCHAR(255), | ||
invoice_status BOOLEAN, | ||
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 , | ||
); |
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.