-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #370 from jc21/develop
v2.2.3
- Loading branch information
Showing
20 changed files
with
436 additions
and
68 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1 +1 @@ | ||
2.2.2 | ||
2.2.3 |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const migrate_name = 'access_list_client'; | ||
const logger = require('../logger').migrate; | ||
|
||
/** | ||
* Migrate | ||
* | ||
* @see http://knexjs.org/#Schema | ||
* | ||
* @param {Object} knex | ||
* @param {Promise} Promise | ||
* @returns {Promise} | ||
*/ | ||
exports.up = function (knex/*, Promise*/) { | ||
|
||
logger.info('[' + migrate_name + '] Migrating Up...'); | ||
|
||
return knex.schema.createTable('access_list_client', (table) => { | ||
table.increments().primary(); | ||
table.dateTime('created_on').notNull(); | ||
table.dateTime('modified_on').notNull(); | ||
table.integer('access_list_id').notNull().unsigned(); | ||
table.string('address').notNull(); | ||
table.string('directive').notNull(); | ||
table.json('meta').notNull(); | ||
|
||
}) | ||
.then(function () { | ||
logger.info('[' + migrate_name + '] access_list_client Table created'); | ||
|
||
return knex.schema.table('access_list', function (access_list) { | ||
access_list.integer('satify_any').notNull().defaultTo(0); | ||
}); | ||
}) | ||
.then(() => { | ||
logger.info('[' + migrate_name + '] access_list Table altered'); | ||
}); | ||
}; | ||
|
||
/** | ||
* Undo Migrate | ||
* | ||
* @param {Object} knex | ||
* @param {Promise} Promise | ||
* @returns {Promise} | ||
*/ | ||
exports.down = function (knex/*, Promise*/) { | ||
logger.info('[' + migrate_name + '] Migrating Down...'); | ||
|
||
return knex.schema.dropTable('access_list_client') | ||
.then(() => { | ||
logger.info('[' + migrate_name + '] access_list_client Table dropped'); | ||
}); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Objection Docs: | ||
// http://vincit.github.io/objection.js/ | ||
|
||
const db = require('../db'); | ||
const Model = require('objection').Model; | ||
|
||
Model.knex(db); | ||
|
||
class AccessListClient extends Model { | ||
$beforeInsert () { | ||
this.created_on = Model.raw('NOW()'); | ||
this.modified_on = Model.raw('NOW()'); | ||
|
||
// Default for meta | ||
if (typeof this.meta === 'undefined') { | ||
this.meta = {}; | ||
} | ||
} | ||
|
||
$beforeUpdate () { | ||
this.modified_on = Model.raw('NOW()'); | ||
} | ||
|
||
static get name () { | ||
return 'AccessListClient'; | ||
} | ||
|
||
static get tableName () { | ||
return 'access_list_client'; | ||
} | ||
|
||
static get jsonAttributes () { | ||
return ['meta']; | ||
} | ||
|
||
static get relationMappings () { | ||
return { | ||
access_list: { | ||
relation: Model.HasOneRelation, | ||
modelClass: require('./access_list'), | ||
join: { | ||
from: 'access_list_client.access_list_id', | ||
to: 'access_list.id' | ||
}, | ||
modify: function (qb) { | ||
qb.where('access_list.is_deleted', 0); | ||
qb.omit(['created_on', 'modified_on', 'is_deleted', 'access_list_id']); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
get rule() { | ||
return `${this.directive} ${this.address}`; | ||
} | ||
} | ||
|
||
module.exports = AccessListClient; |
Oops, something went wrong.