Files
speckle-server/packages/server/modules/core/migrations
Cristian Balas 9d254e7142 Keep commits of deleted users to other streams, but set the user reference to null (#276)
* Keep commits of deleted users to other streams, but set the user reference to null

* fix(server): user deletion fixes; updates tests

includes one failing assert that needs to be fixed

* fix(server): left join on users in commit services to handle null author cases

* fix(server): ditto, caught one more join -> leftJoin case

* test(server): user deletion test wrap-ip

catches all commit/branches with null authors re services

* fix(server): unqualified delete syntax error - thanks JS!

Co-authored-by: Dimitrie Stefanescu <didimitrie@gmail.com>
2021-06-07 08:08:04 +03:00
..

Migrations, and how to create them

First, make a new migration file:

  • cd ${migrations folder}
  • knex migrate:make ${your migration name}

Next, write your migration! Here's an example below that adds a new column to a table.


/* istanbul ignore file */
exports.up = async ( knex ) => {
  await knex.schema.alterTable( 'scopes', table => {
    table.boolean( 'public' ).defaultTo( true )
  } )
}

exports.down = async ( knex ) => {
  let hasColumn = await knex.schema.hasColumn( 'scopes', 'public' )
  if ( hasColumn ) {
    await knex.schema.alterTable( 'scopes', table => {
      table.dropColumn( 'public' )
    } )
  }
}

Notes:

  • Do not delete or edit existing migration files
  • To edit an existing table, use alter table in a new migration file.
  • Always prefix your migration file with the date that you authored it in.