Migrations

Fizz Migrations

Buffalo uses Fizz to generate migrations that are both easy to work with and work across multiple types of databases.

$ buffalo db g migration --help

Generates Up/Down migrations for your database using fizz.

Usage:
  buffalo db generate fizz [name] [flags]

Aliases:
  fizz, migration


Global Flags:
  -c, --config string   The configuration file you would like to use.
  -d, --debug           Use debug/verbose mode
  -e, --env string      The environment you want to run migrations against. Will use $GO_ENV if set. (default "development")
  -p, --path string     Path to the migrations folder (default "./migrations")

SQL Migrations

If you don't want to use Fizz, or you have a complicated query you want to execute, you can use SQL.

$ buffalo db g sql --help

Generates Up/Down migrations for your database using SQL.

Usage:
  buffalo db generate sql [name] [flags]

Global Flags:
  -c, --config string   The configuration file you would like to use.
  -d, --debug           Use debug/verbose mode
  -e, --env string      The environment you want to run migrations against. Will use $GO_ENV if set. (default "development")
  -p, --path string     Path to the migrations folder (default "./migrations")

Running Migrations

Once migrations have been created they can be run with either of the following commands:

$ buffalo db migrate
$ buffalo db migrate up

Both commands are identical, one is shorter to type!

More information about the migration command be found by running:

$ buffalo db migrate --help

Runs migrations against your database.

Usage:
  buffalo db migrate [flags]
  buffalo db migrate [command]

Aliases:
  migrate, m


Available Commands:
  down        Apply all of the 'down' migrations.
  reset       The equivalent of running `migrate down` and then `migrate up`
  up          Apply all of the 'up' migrations.

Global Flags:
  -c, --config string   The configuration file you would like to use.
  -d, --debug           Use debug/verbose mode
  -e, --env string      The environment you want to run migrations against. Will use $GO_ENV if set. (default "development")
  -p, --path string     Path to the migrations folder (default "./migrations")

Use "buffalo db migrate [command] --help" for more information about a command.

Copyright © 2017 Buffalo. All rights reserved.

Buffalo Gopher designed by Ashley McNamara — Original Gopher designed by Renee French.