lukeed / ley

(WIP) Driver-agnostic database migrations
MIT License
259 stars 14 forks source link

Create new migration by CLI #2

Closed alexeymarunin closed 4 years ago

alexeymarunin commented 4 years ago

Is there the way to create new migration (or migration skeleton, with empty up and down methods) by CLI command?

For example

ley generate --prefix-timestamp add-users-table

will create file 1581760315-add-users-table.js

lukeed commented 4 years ago

Hey :) Maybe haha. Certainly wouldn't add it to the programmatic API. I'm just afraid that adding it to the CLI is kinda useless since it's such a simple file structure, and even a generalized stub would likely need user-tweaking

exports.up = async client => {
  //
}

exports.down = async client => {
  //
}

In the meantime, you can certainly do this:

$ touch "$(date +%s)-create-users.js"
#=> 1581785004-create-users.js

If ley were to add this, it'd look something like:

$ ley new create-users --timestamp