Skip to content

Commit

Permalink
README: Add introduction text and workflow overview
Browse files Browse the repository at this point in the history
  • Loading branch information
GeertJohan committed Jan 7, 2024
1 parent 581c6d8 commit d326271
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# trek

Trek is a tool that assists in postgres schema development and deployment. Trek provides a unified and simple workflow for developers to change the database schema and commit versioned migration files to a SCM such as git. Trek also helps with rolling out those migrations to a live database.

A basic trek workflow looks like this:
- Initialize a trek directory `mkdir my_database; cd my_database; trek init`
- Change the database schema by using the [pgModeler](https://github.com/pgmodeler/pgmodeler) GUI.
- Run trek to generate a new migration file. The migration file will contain all changes since the last version as postgres DDL (ALTER TABLE, etc.). The migration file is stored as file in the `my_database/migrations` folder.
- Commit the migration file to an SCM like git. The changed pgModeler schema and the migration SQL file may be code-reviewed.
- Deploy the latest version of `my_database` to a live database by running `trek apply`. Trek uses [golang-migrate](https://github.com/golang-migrate/migrate) to keep track of the latest version deployed to a database, and to deploy new migration files to the database. (You may skip `trek apply` and integrate with `golang-migrate` manually.)

A developer could run `trek generate --stdout` to continuously watch the pgmodeler model for updates (on save) and write postgres DDL to stdout.

Trek is an opinionated tool. We built it to do one thing and do it well: convert pgmodeler schema design into versioned migrations. Trek is exclusively designed for use with PostgreSQL, and we firmly intend to maintain this focus. As such, we will not be considering or adding support for any other database systems.

## Requirements
At least version 13 of postgres is needed.

Expand All @@ -11,7 +24,7 @@ go install .

## Dependencies

Trek depends on `migra` and `pgmodeler-cli`. Trek will try to locate these in the `$PATH` of the user.
Running `trek generate` requires to have `migra` and `pgmodeler-cli` installed. Trek will try to locate these in the `$PATH` of the user.

If `migra` cannot be found, trek will try use versions of this binary that is embedded into the trek build. The user can skip searching for `migra` in the path by setting `TREK_FORCE_EMBEDDED_MIGRA`. For example:

Expand Down

0 comments on commit d326271

Please sign in to comment.