Skip to content

Commit

Permalink
feat(defaultColumn): add conventions of default columns
Browse files Browse the repository at this point in the history
Signed-off-by: Tobias Gurtzick <magic@wizardtales.com>
  • Loading branch information
wzrdtales committed Jun 15, 2019
1 parent edc8d08 commit c3a1583
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/executors/versioned/v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const Chain = require('../../chain');
const StateTravel = require('../../methods/v2/statetravel');
const Migrate = require('../../methods/v2/migrate');
const TranslateState = require('../../methods/v2/translatestate');
const AddConventions = require('../../methods/v2/conventions');

const execUnit = {
_extend: (context, type) => {
Expand All @@ -28,6 +29,7 @@ const execUnit = {
up: async function (context, driver, file) {
const _file = file.get();
const chain = new Chain(context._driver, file, driver, context.internals);
chain.addChain(AddConventions);
chain.addChain(Learn);
chain.addChain(StateTravel);
chain.addChain(Migrate);
Expand Down
47 changes: 47 additions & 0 deletions lib/methods/v2/conventions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const Shadow = require('../../driver/shadow');

class AddConventions {
constructor (internals, file, driver) {
this.file = file;
this.internals = internals;
this.driver = driver;
this._counter = 0;
}

createTable (t, d) {
d['__dbmigrate__flag'] = {
type: 'string'
};

return Promise.resolve();
}

createCollection (...args) {
return this.createTable.apply(this, args);
}
}

const noAction = prop => {
return function () {
return Promise.resolve();
};
};

module.exports = {
getInterface: (context, file, driver, internals) => {
if (context.conventions) {
const st = new AddConventions(internals, file, context);
return Shadow.overshadow(
driver,
Object.assign(st, context.conventions),
noAction
);
}

return Shadow.overshadow(
driver,
new AddConventions(internals, file, context),
noAction
);
}
};

0 comments on commit c3a1583

Please sign in to comment.