Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we create integer array type column in knex migration?

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.

like image 777
Sudhir Roy Avatar asked Dec 06 '22 12:12

Sudhir Roy


1 Answers

You can use the specificType method for that:

knex.schema.createTable('deal', function(t) {
  t.increments()
  t.specificType('deal', 'INT[]')
})
like image 88
devius Avatar answered Jan 12 '23 16:01

devius