Skip to content

Commit

Permalink
fix(timestamps): only create timestamp triggers when necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
haltcase committed Jun 24, 2019
1 parent c901d98 commit 35dbab6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as knex from 'knex'

import Model from './model'
import { runQuery } from './helpers'
import { toKnexSchema, createTimestampTrigger } from './schema-helpers'
import { toKnexSchema } from './schema-helpers'
import { pureConnect } from './sqljs-handler'
import { defaultTo, invariant, makeDirPath } from './util'

Expand Down Expand Up @@ -147,8 +147,6 @@ export class Trilogy {
}
}

// tslint:disable-next-line:no-floating-promises
createTimestampTrigger(model)
return model
}

Expand Down
3 changes: 3 additions & 0 deletions src/schema-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ export function toKnexSchema <D extends types.ReturnDict> (
const value = (options as any)[key]
if (key === 'timestamps' && options.timestamps) {
table.timestamps(false, true)

// tslint:disable-next-line:no-floating-promises
createTimestampTrigger(model)
} else if (key === 'index') {
createIndices(table, value)
} else {
Expand Down

0 comments on commit 35dbab6

Please sign in to comment.