Skip to content

Commit

Permalink
feat: add taxable column for billing (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajohn25 authored Jul 2, 2024
1 parent 68b8d83 commit 8058282
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
49 changes: 49 additions & 0 deletions migrations/20240702164031-add-client-tax.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
'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', '20240702164031-add-client-tax-up.sql');
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
if (err) return reject(err);
resolve(data);
});
})
.then(function(data) {
return db.runSql(data);
});
};

exports.down = function(db) {
var filePath = path.join(__dirname, 'sqls', '20240702164031-add-client-tax-down.sql');
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
if (err) return reject(err);
resolve(data);
});
})
.then(function(data) {
return db.runSql(data);
});
};

exports._meta = {
"version": 1
};
1 change: 1 addition & 0 deletions migrations/sqls/20240702164031-add-client-tax-down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table billing.clients drop column taxable;
1 change: 1 addition & 0 deletions migrations/sqls/20240702164031-add-client-tax-up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table billing.clients add column taxable boolean not null default false;
3 changes: 2 additions & 1 deletion schema-dump.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2961,7 +2961,8 @@ CREATE TABLE billing.clients (
id uuid DEFAULT public.uuid_generate_v1mc() NOT NULL,
name text NOT NULL,
access_token text DEFAULT md5((random())::text),
created_at timestamp without time zone DEFAULT now() NOT NULL
created_at timestamp without time zone DEFAULT now() NOT NULL,
taxable boolean DEFAULT false NOT NULL
);


Expand Down

0 comments on commit 8058282

Please sign in to comment.