Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Migration class to handle migrations #5

Open
jlenon7 opened this issue Mar 15, 2022 · 0 comments
Open

Implement Migration class to handle migrations #5

jlenon7 opened this issue Mar 15, 2022 · 0 comments
Assignees
Labels
documentation Improvements or additions to documentation feature New feature or request

Comments

@jlenon7
Copy link
Contributor

jlenon7 commented Mar 15, 2022

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

@jlenon7 jlenon7 added documentation Improvements or additions to documentation feature New feature or request labels Mar 15, 2022
@jlenon7 jlenon7 self-assigned this Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant