@@ -7,7 +7,7 @@ const logger = require('../common/logger')
7
7
const helper = require ( '../common/helper' )
8
8
9
9
const QUERY_GET_ENTRIES = 'SELECT user_id FROM user_terms_of_use_xref WHERE terms_of_use_id = %d'
10
- const QUERY_INSERT_ENTRY = 'INSERT INTO user_terms_of_use_xref (user_id, terms_of_use_id, create_date, modify_date) VALUES (?, ?, ?, ? )'
10
+ const QUERY_INSERT_ENTRY = 'INSERT INTO user_terms_of_use_xref (user_id, terms_of_use_id, create_date, modify_date) VALUES (?, ?, CURRENT, CURRENT )'
11
11
12
12
/**
13
13
* Prepare Informix statement
@@ -49,9 +49,12 @@ async function createEntry (termsOfUseId, memberId) {
49
49
let result = null
50
50
try {
51
51
// await connection.beginTransactionAsync()
52
- const currentDateIso = new Date ( ) . toISOString ( ) . replace ( 'T' , ' ' ) . replace ( 'Z' , '' ) . split ( '.' ) [ 0 ]
53
52
const query = await prepare ( connection , QUERY_INSERT_ENTRY )
54
- result = await query . executeAsync ( [ termsOfUseId , memberId , currentDateIso , currentDateIso ] )
53
+ if ( config . SYNC_V5_WRITE_ENABLED ) {
54
+ result = await query . executeAsync ( [ memberId , termsOfUseId ] )
55
+ } else {
56
+ logger . debug ( `INSERT INTO user_terms_of_use_xref (user_id, terms_of_use_id, create_date, modify_date) VALUES (${ memberId } , ${ termsOfUseId } , CURRENT, CURRENT)` )
57
+ }
55
58
// await connection.commitTransactionAsync()
56
59
} catch ( e ) {
57
60
logger . error ( `Error in 'createEntry' ${ e } , rolling back transaction` )
@@ -114,12 +117,7 @@ async function main () {
114
117
logger . debug ( `Found ${ legacyIntries . length } users` )
115
118
for ( const memberId of v5Entries ) {
116
119
if ( legacyIntries . indexOf ( memberId ) === - 1 ) {
117
- if ( config . SYNC_V5_WRITE_ENABLED ) {
118
- await createEntry ( legacyTermId , memberId )
119
- } else {
120
- const currentDateIso = new Date ( ) . toISOString ( ) . replace ( 'T' , ' ' ) . replace ( 'Z' , '' ) . split ( '.' ) [ 0 ]
121
- logger . debug ( `INSERT INTO user_terms_of_use_xref (user_id, terms_of_use_id, create_date, modify_date) VALUES (${ legacyTermId } , ${ memberId } , ${ currentDateIso } , ${ currentDateIso } )` )
122
- }
120
+ await createEntry ( legacyTermId , memberId )
123
121
}
124
122
}
125
123
logger . info ( 'Completed!' )
0 commit comments