Linux command
goose 命令
文本
涉及管道、覆盖或删除,执行前请先确认路径和参数。
常用示例
Create
goose create [migration-name] [sql|go]
Apply
goose up
Rollback
goose down
Check
goose status
说明
goose is a database migration tool that supports both SQL and Go migrations. It manages database schema changes by versioning migration files and tracking which migrations have been applied. The tool supports PostgreSQL, MySQL, SQLite, SQL Server, and other databases, providing a consistent interface for schema migrations.
参数
- up
- Migrate up
- up-by-one
- Migrate up by one version
- down
- Migrate down
- down-to _VERSION_
- Migrate down to specific version
- status
- Show migration status
- create _NAME_ _TYPE_
- Create new migration (sql or go)
- fix
- Apply sequential ordering to migrations
- version
- Print goose version
- -dir _DIR_
- Migrations directory (default: migrations)
- -table _TABLE_
- Migrations table name (default: goose_db_version)
- -s, --allow-missing
- Allow missing migrations
- -v, --version
- Display version and exit
- -h, --help
- Display help and exit
FAQ
What is the goose command used for?
goose is a database migration tool that supports both SQL and Go migrations. It manages database schema changes by versioning migration files and tracking which migrations have been applied. The tool supports PostgreSQL, MySQL, SQLite, SQL Server, and other databases, providing a consistent interface for schema migrations.
How do I run a basic goose example?
Run `goose create [migration-name] [sql|go]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does up do in goose?
Migrate up