Skip to content

Implement Migration class to handle migrations #5

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationfeatureNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions