How do you create a TINYINT column with Knex?

In the knex documentation, I only see the option to create an integer or biginteger.

For example, say I have a movies table with a rating column to store a movie’s 5 star rating:

// Migration script  exports.up = knex => {   return knex.schema     .createTable('movies', table => {       table.uuid('id').primary()       ...       table.integer('rating') // <-- I want this to be a TINYINT     }) } 

Is there a way to do this without resorting to a raw SQL query?

Add Comment
1 Answer(s)

You can use specificType as below:

table.specificType('rating', 'tinyint(1)') 
Answered on July 16, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.