Preview:
import { Knex } from "knex";

export async function up(knex: Knex)  {
    if(!await knex.schema.hasTable("students")){
        await knex.schema.createTable("students",(table)=>{
            table.increments();
            table.string("name");
            table.string("level");
            table.date("date_of_birth");
            table.integer("teacher_id").unsigned();
            table.foreign('teacher_id').references('teachers.id');
            table.timestamps(false,true);
        });
    }
};

export async function down(knex: Knex){
    await knex.schema.dropTableIfExists("students");
};
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter