File tree Expand file tree Collapse file tree 13 files changed +62
-37
lines changed Expand file tree Collapse file tree 13 files changed +62
-37
lines changed Original file line number Diff line number Diff line change @@ -6,13 +6,14 @@ const Model = require('objection').Model;
66const User = require ( './user' ) ;
77const AccessListAuth = require ( './access_list_auth' ) ;
88const AccessListClient = require ( './access_list_client' ) ;
9+ const now = require ( './now_helper' ) ;
910
1011Model . knex ( db ) ;
1112
1213class AccessList extends Model {
1314 $beforeInsert ( ) {
14- this . created_on = Model . raw ( 'NOW()' ) ;
15- this . modified_on = Model . raw ( 'NOW()' ) ;
15+ this . created_on = now ( ) ;
16+ this . modified_on = now ( ) ;
1617
1718 // Default for meta
1819 if ( typeof this . meta === 'undefined' ) {
@@ -21,7 +22,7 @@ class AccessList extends Model {
2122 }
2223
2324 $beforeUpdate ( ) {
24- this . modified_on = Model . raw ( 'NOW()' ) ;
25+ this . modified_on = now ( ) ;
2526 }
2627
2728 static get name ( ) {
Original file line number Diff line number Diff line change 33
44const db = require ( '../db' ) ;
55const Model = require ( 'objection' ) . Model ;
6+ const now = require ( './now_helper' ) ;
67
78Model . knex ( db ) ;
89
910class AccessListAuth extends Model {
1011 $beforeInsert ( ) {
11- this . created_on = Model . raw ( 'NOW()' ) ;
12- this . modified_on = Model . raw ( 'NOW()' ) ;
12+ this . created_on = now ( ) ;
13+ this . modified_on = now ( ) ;
1314
1415 // Default for meta
1516 if ( typeof this . meta === 'undefined' ) {
@@ -18,7 +19,7 @@ class AccessListAuth extends Model {
1819 }
1920
2021 $beforeUpdate ( ) {
21- this . modified_on = Model . raw ( 'NOW()' ) ;
22+ this . modified_on = now ( ) ;
2223 }
2324
2425 static get name ( ) {
Original file line number Diff line number Diff line change 33
44const db = require ( '../db' ) ;
55const Model = require ( 'objection' ) . Model ;
6+ const now = require ( './now_helper' ) ;
67
78Model . knex ( db ) ;
89
910class AccessListClient extends Model {
1011 $beforeInsert ( ) {
11- this . created_on = Model . raw ( 'NOW()' ) ;
12- this . modified_on = Model . raw ( 'NOW()' ) ;
12+ this . created_on = now ( ) ;
13+ this . modified_on = now ( ) ;
1314
1415 // Default for meta
1516 if ( typeof this . meta === 'undefined' ) {
@@ -18,7 +19,7 @@ class AccessListClient extends Model {
1819 }
1920
2021 $beforeUpdate ( ) {
21- this . modified_on = Model . raw ( 'NOW()' ) ;
22+ this . modified_on = now ( ) ;
2223 }
2324
2425 static get name ( ) {
Original file line number Diff line number Diff line change 44const db = require ( '../db' ) ;
55const Model = require ( 'objection' ) . Model ;
66const User = require ( './user' ) ;
7+ const now = require ( './now_helper' ) ;
78
89Model . knex ( db ) ;
910
1011class AuditLog extends Model {
1112 $beforeInsert ( ) {
12- this . created_on = Model . raw ( 'NOW()' ) ;
13- this . modified_on = Model . raw ( 'NOW()' ) ;
13+ this . created_on = now ( ) ;
14+ this . modified_on = now ( ) ;
1415
1516 // Default for meta
1617 if ( typeof this . meta === 'undefined' ) {
@@ -19,7 +20,7 @@ class AuditLog extends Model {
1920 }
2021
2122 $beforeUpdate ( ) {
22- this . modified_on = Model . raw ( 'NOW()' ) ;
23+ this . modified_on = now ( ) ;
2324 }
2425
2526 static get name ( ) {
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ const bcrypt = require('bcrypt');
55const db = require ( '../db' ) ;
66const Model = require ( 'objection' ) . Model ;
77const User = require ( './user' ) ;
8+ const now = require ( './now_helper' ) ;
89
910Model . knex ( db ) ;
1011
@@ -24,8 +25,8 @@ function encryptPassword () {
2425
2526class Auth extends Model {
2627 $beforeInsert ( queryContext ) {
27- this . created_on = Model . raw ( 'NOW()' ) ;
28- this . modified_on = Model . raw ( 'NOW()' ) ;
28+ this . created_on = now ( ) ;
29+ this . modified_on = now ( ) ;
2930
3031 // Default for meta
3132 if ( typeof this . meta === 'undefined' ) {
@@ -36,7 +37,7 @@ class Auth extends Model {
3637 }
3738
3839 $beforeUpdate ( queryContext ) {
39- this . modified_on = Model . raw ( 'NOW()' ) ;
40+ this . modified_on = now ( ) ;
4041 return encryptPassword . apply ( this , queryContext ) ;
4142 }
4243
Original file line number Diff line number Diff line change 44const db = require ( '../db' ) ;
55const Model = require ( 'objection' ) . Model ;
66const User = require ( './user' ) ;
7+ const now = require ( './now_helper' ) ;
78
89Model . knex ( db ) ;
910
1011class Certificate extends Model {
1112 $beforeInsert ( ) {
12- this . created_on = Model . raw ( 'NOW()' ) ;
13- this . modified_on = Model . raw ( 'NOW()' ) ;
13+ this . created_on = now ( ) ;
14+ this . modified_on = now ( ) ;
1415
1516 // Default for expires_on
1617 if ( typeof this . expires_on === 'undefined' ) {
17- this . expires_on = Model . raw ( 'NOW()' ) ;
18+ this . expires_on = now ( ) ;
1819 }
1920
2021 // Default for domain_names
@@ -31,7 +32,7 @@ class Certificate extends Model {
3132 }
3233
3334 $beforeUpdate ( ) {
34- this . modified_on = Model . raw ( 'NOW()' ) ;
35+ this . modified_on = now ( ) ;
3536
3637 // Sort domain_names
3738 if ( typeof this . domain_names !== 'undefined' ) {
Original file line number Diff line number Diff line change @@ -5,13 +5,14 @@ const db = require('../db');
55const Model = require ( 'objection' ) . Model ;
66const User = require ( './user' ) ;
77const Certificate = require ( './certificate' ) ;
8+ const now = require ( './now_helper' ) ;
89
910Model . knex ( db ) ;
1011
1112class DeadHost extends Model {
1213 $beforeInsert ( ) {
13- this . created_on = Model . raw ( 'NOW()' ) ;
14- this . modified_on = Model . raw ( 'NOW()' ) ;
14+ this . created_on = now ( ) ;
15+ this . modified_on = now ( ) ;
1516
1617 // Default for domain_names
1718 if ( typeof this . domain_names === 'undefined' ) {
@@ -27,7 +28,7 @@ class DeadHost extends Model {
2728 }
2829
2930 $beforeUpdate ( ) {
30- this . modified_on = Model . raw ( 'NOW()' ) ;
31+ this . modified_on = now ( ) ;
3132
3233 // Sort domain_names
3334 if ( typeof this . domain_names !== 'undefined' ) {
Original file line number Diff line number Diff line change 1+ const db = require ( '../db' ) ;
2+ const config = require ( 'config' ) ;
3+ const Model = require ( 'objection' ) . Model ;
4+
5+ Model . knex ( db ) ;
6+
7+ module . exports = function ( ) {
8+ if ( config . database . knex && config . database . knex . client === 'sqlite3' ) {
9+ return Model . raw ( 'date(\'now\')' ) ;
10+ } else {
11+ return Model . raw ( 'NOW()' ) ;
12+ }
13+ } ;
Original file line number Diff line number Diff line change @@ -6,13 +6,14 @@ const Model = require('objection').Model;
66const User = require ( './user' ) ;
77const AccessList = require ( './access_list' ) ;
88const Certificate = require ( './certificate' ) ;
9+ const now = require ( './now_helper' ) ;
910
1011Model . knex ( db ) ;
1112
1213class ProxyHost extends Model {
1314 $beforeInsert ( ) {
14- this . created_on = Model . raw ( 'NOW()' ) ;
15- this . modified_on = Model . raw ( 'NOW()' ) ;
15+ this . created_on = now ( ) ;
16+ this . modified_on = now ( ) ;
1617
1718 // Default for domain_names
1819 if ( typeof this . domain_names === 'undefined' ) {
@@ -28,7 +29,7 @@ class ProxyHost extends Model {
2829 }
2930
3031 $beforeUpdate ( ) {
31- this . modified_on = Model . raw ( 'NOW()' ) ;
32+ this . modified_on = now ( ) ;
3233
3334 // Sort domain_names
3435 if ( typeof this . domain_names !== 'undefined' ) {
Original file line number Diff line number Diff line change @@ -5,13 +5,14 @@ const db = require('../db');
55const Model = require ( 'objection' ) . Model ;
66const User = require ( './user' ) ;
77const Certificate = require ( './certificate' ) ;
8+ const now = require ( './now_helper' ) ;
89
910Model . knex ( db ) ;
1011
1112class RedirectionHost extends Model {
1213 $beforeInsert ( ) {
13- this . created_on = Model . raw ( 'NOW()' ) ;
14- this . modified_on = Model . raw ( 'NOW()' ) ;
14+ this . created_on = now ( ) ;
15+ this . modified_on = now ( ) ;
1516
1617 // Default for domain_names
1718 if ( typeof this . domain_names === 'undefined' ) {
@@ -27,7 +28,7 @@ class RedirectionHost extends Model {
2728 }
2829
2930 $beforeUpdate ( ) {
30- this . modified_on = Model . raw ( 'NOW()' ) ;
31+ this . modified_on = now ( ) ;
3132
3233 // Sort domain_names
3334 if ( typeof this . domain_names !== 'undefined' ) {
You can’t perform that action at this time.
0 commit comments