Skip to content

Implement Migration class to handle migrations #5

@jlenon7

Description

@jlenon7

Description

Database class has the methods createTable and dropTable. But it does not have the same behavior that a Migration has with up and down method.

Usage example (this is just an example and could change when developing Schema):

import { Migration } from '@secjs/database'

export class UsersMigration extends Migration {
  protected tableName = 'users'

  public async up() {
    this.createTable(this.tableName, (table) => {
      table.increments('id').primary()
      table.string('name').nullable()
      table.timestamp('created_at', { useTz: true })
      table.timestamp('updated_at', { useTz: true })
    })
  }

  public async down() {
    this.dropTable(this.tableName)
  }
}

Package version

1.0.1

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationfeatureNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions