Skip to content

Commit c3a1583

Browse files
committed
feat(defaultColumn): add conventions of default columns
Signed-off-by: Tobias Gurtzick <[email protected]>
1 parent edc8d08 commit c3a1583

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

lib/executors/versioned/v2.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const Chain = require('../../chain');
88
const StateTravel = require('../../methods/v2/statetravel');
99
const Migrate = require('../../methods/v2/migrate');
1010
const TranslateState = require('../../methods/v2/translatestate');
11+
const AddConventions = require('../../methods/v2/conventions');
1112

1213
const execUnit = {
1314
_extend: (context, type) => {
@@ -28,6 +29,7 @@ const execUnit = {
2829
up: async function (context, driver, file) {
2930
const _file = file.get();
3031
const chain = new Chain(context._driver, file, driver, context.internals);
32+
chain.addChain(AddConventions);
3133
chain.addChain(Learn);
3234
chain.addChain(StateTravel);
3335
chain.addChain(Migrate);

lib/methods/v2/conventions.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
const Shadow = require('../../driver/shadow');
2+
3+
class AddConventions {
4+
constructor (internals, file, driver) {
5+
this.file = file;
6+
this.internals = internals;
7+
this.driver = driver;
8+
this._counter = 0;
9+
}
10+
11+
createTable (t, d) {
12+
d['__dbmigrate__flag'] = {
13+
type: 'string'
14+
};
15+
16+
return Promise.resolve();
17+
}
18+
19+
createCollection (...args) {
20+
return this.createTable.apply(this, args);
21+
}
22+
}
23+
24+
const noAction = prop => {
25+
return function () {
26+
return Promise.resolve();
27+
};
28+
};
29+
30+
module.exports = {
31+
getInterface: (context, file, driver, internals) => {
32+
if (context.conventions) {
33+
const st = new AddConventions(internals, file, context);
34+
return Shadow.overshadow(
35+
driver,
36+
Object.assign(st, context.conventions),
37+
noAction
38+
);
39+
}
40+
41+
return Shadow.overshadow(
42+
driver,
43+
new AddConventions(internals, file, context),
44+
noAction
45+
);
46+
}
47+
};

0 commit comments

Comments
 (0)