Skip to content

Shared columns? #1146

Closed Answered by mike-usa
magick93 asked this question in Q&A
Discussion options

You must be logged in to vote

I'm just learning node-pg-migrate, so take this for what it's worth. It sounds like you could make use of shorthands.

Here is syntax I've used:

const { PgLiteral } = require('node-pg-migrate')

let current_user_id = 123456; // <-- use an environment variable or perform a lookup against the `users` table
exports.shorthands = {
  ':created_by': {type: 'integer',   notNull: true,  references: 'users', default: current_user_id},
  ':created_at': {type: 'timestamp', notNull: true,                       default: new PgLiteral('current_timestamp')}
  ':updated_by': {type: 'integer',                   references: 'users'},
  ':updated_at': {type: 'timestamp}
}

pgm.createTable('entries', {
  id: 'id

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Shinigami92
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #892 on May 02, 2024 08:50.