Files
speckle-server/packages/server/modules/core/migrations
Gergő Jedlicska 7c16abc8eb feat(workspace): 1119 define workspaces dataschema (#2431)
* feat(workspaces): add workspaces module with roles and scopes

* feat(workspaces): add domain, graphql and persistent storage dataschema

* fix(workspaces): correct db injections

* chore(workspaces): add EE license

* chore(license): mentions workspaces separately in license file

* fix(core): roles import in migration

* fix(workspaces): drop workspace_acl on down migration

* fix(workspaces): roles constants

* fix(workspaces): coding standards

---------

Co-authored-by: Dimitrie Stefanescu <didimitrie@gmail.com>
2024-06-26 17:00:56 +02:00
..
2022-03-29 16:30:49 +03:00

Migrations, and how to create them

First, make a new migration file in the appropriate migrations folder. To do this use ./bin/cli.

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.