6

I have a table something like this:

Table: Deal Columns: Id int, deal int[]

Each entry in deal array references some other table id. How can we create the migration for the structure? Also, how can we create array column in knex for postgres.

Sudhir Roy
  • 256
  • 2
  • 3
  • 11

2 Answers2

19

You can use the specificType method for that:

knex.schema.createTable('deal', function(t) {
  t.increments()
  t.specificType('deal', 'INT[]')
})
devius
  • 2,736
  • 22
  • 26
1
knex.schema.createTable('deal', function(t) 
{ 
    t.increments(),
    t.specificType('deal', 'integer ARRAY')
})

One can like this aswell.

krishnazden
  • 1,127
  • 10
  • 19