The database
or db
command is one of the most common command that you will be operating. This command allows you to work with the database engine of choice when the Amber application was generated.
Here is a list of the commands available:
create Creates the database for the environment specified in your configuration file.
drop Drops the database for the environment specified in your configuration file.
migrate or m Migrates up
or down
the database version
rollback Rolls back your database to a specific version or to previous version
redo Repeats the database version specified or lasted version
status Prints the current database migration status
seed Adds initial data after a database is created
version Prints the database current version.
amber database [COMMANDS1 COMMANDS2...]​Arguments:COMMANDS (Accepts multiple) drop create migrate rollback redo status version seed
$ amber db createCreated database blog_development
Starting with version 0.3.5 - Amber made two changes regarding databases:
Amber will substitute hyphens -
for underscores _
in database names to keep it PostgreSQL friendly.
The default user for pg
databases is postgres
rather than root
in your configuration file.
postgres://postgres:@localhost:5432/microsecond_blog_development
$ amber new microsecond-blog$ cd microsecond-blog$ amber db createCreated database microsecond_blog_development
$ amber db dropDropped database blog_development
$ amber db migrateMigrating db, current version: 0, target: 20170928204246OK 20170928204246_create_post.sql
$ amber db rollbackMigrating db, current version: 20170928204246, target: 0OK 20170928204246_create_post.sql
$ amber db redoMigrating db, current version: 20170928204246, target: 0OK 20170928204246_create_post.sqlMigrating db, current version: 0, target: 20170928204246OK 20170928204246_create_post.sql
$ amber db statusApplied At Migration=======================================2017-09-28 20:44:22 UTC -- 20170928204246_create_post.sql
$ amber db seedSeeded database
$ amber db version20170928204246