knexjs execute all migrations

Solutions on MaxInterview for knexjs execute all migrations by the best coders in the world

showing results for - "knexjs execute all migrations"
Emely
17 Feb 2018
1// modified by Emmanuel Mahuni to use async/await more readable code
2exports.up = async function(knex) {
3 	await knex.schema.createTable('table_b', t => {
4      t.string('col_a')
5      t.string('col_b')
6    })
7  
8    await knex.schema.createTable('table_c', t => {
9      t.string('col_c')
10      t.string('col_d')
11    })
12  
13    let rows = await knex('table_a').select('col_a', 'col_b')
14    await knex('table_b').insert(rows)
15    
16  	rows = await knex('table_a').select('col_c', 'col_d')
17    await knex('table_c').insert(rows)
18  
19    await knex.schema.dropTableIfExists('table_a'))
20};
21
22exports.down = async function(knex) {
23  await knex.schema.createTable('table_a', t => {
24      t.string('col_a')
25      t.string('col_b')
26      t.string('col_c')
27      t.string('col_d')
28    })
29  
30  let rows = await knex('table_b').select('col_a', 'col_b')
31  await knex('table_a').insert(rows)
32  
33  rows = await knex('table_c').select('col_c', 'col_d')
34  await knex('table_a').insert(rows)
35  
36  await knex.schema.dropTableIfExists('table_b')
37  await knex.schema.dropTableIfExists('table_c')
38};
39
Giulia
12 Oct 2020
1  table.increments('id')
2  table.string('account_name')
3  table.integer('age')
4  table.float('age')
5  table.decimal('balance', 8, 2)
6  table.boolean('is_admin')
7  table.date('birthday')
8  table.time('created_at')
9  table.timestamp('created_at').defaultTo(knex.fn.now())
10  table.json('profile')
11  table.jsonb('profile')
12  table.uuid('id').primary()
13
Maeve
01 Jun 2016
1$ knex migrate:make create_users_table
2$ knex migrate:make create_tasks_table
similar questions
queries leading to this page
knexjs execute all migrations