schemer

command module
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2025 License: MIT Imports: 4 Imported by: 0

README ΒΆ

Schemer

Schemer is a lightweight, delta-based database migration tool for PostgreSQL.


πŸš€ Features

  • Versioned .sql delta files (up, down, and optional post)
  • Apply deltas in order or cherry-pick specific versions
  • Post-delta support for deferred cleanup of corresponding Up-deltas
  • Schema state tracked via a dedicated schemer table
  • Simple .env-based configuration optional

πŸ“¦ Installation

Ensure you have go installed,

go install github.com/yourusername/schemer@latest

Ensure $GOPATH/bin is in your system PATH.


πŸ“ Delta Format

Deltas live in the deltas/ directory and follow this naming convention:

<version>_<name>.<type>.sql
  • <version> β€” zero-padded integer (e.g. 001)
  • <name> β€” descriptive name (e.g. add_users)
  • <type> β€” one of up, down, or post
Example
deltas/
β”œβ”€β”€ 001_add_users.up.sql
β”œβ”€β”€ 001_add_users.down.sql
β”œβ”€β”€ 001_add_users.post.sql  # optional

πŸ›  Commands

schemer init

Bootstraps a new project in the current directory:

  • Creates a deltas/ directory
  • Generates a .env file with DATABASE_URL
  • Writes a schemer.sql template
Should only be used on new projects and never in a production
environment.

schemer create <name>

Creates a versioned delta group:

schemer create add_users

This creates:

deltas/002_add_users.up.sql
deltas/002_add_users.down.sql
deltas/002_add_users.post.sql  # only if --post is used

schemer up [options]

Default behaviour: Applies all unapplied up deltas.

Options:

  • --from <tag> β€” start from a specific tag
  • --to <tag> β€” apply up to a tag
  • --cherry-pick <tag> <tag> β€” apply specific tags
  • --prune β€” skip no-op deltas

schemer down [options]

Default behaviour: Rolls back last applied delta.

Options:

  • --from <tag> β€” rollback from this tag
  • --to <tag> β€” rollback down to this tag
  • --cherry-pick <tag> <tag> β€” rollback specific tags
  • --prune β€” skip no-op deltas

schemer post [options]

Default behaviour: Applies all post deltas for all recorded up deltas.

Options:

  • --from <tag> / --to <tag> β€” limit range
  • --cherry-pick <tag> <tag> β€” apply specific posts
  • --force β€” apply untracked post deltas

πŸ§ͺ Examples

schemer init
schemer create create_users --post
schemer up
schemer down --from 003
schemer post --cherry-pick 003 --force

πŸ“„ .env File

In a dev environment Schemer reads the connection string from a .env file: You can provide a postgres connection string with --url or a environment varible key name with --key. When initalizing Schemre with init you can provide both --url and --key to have Schemer write the key and value to the .env file.

DATABASE_URL=postgres://user:pass@localhost:5432/mydb?sslmode=disable

πŸ“Š Schemer Table

A schemer table tracks:

  • Applied delta tags
  • Post delta status

It's created during init or the first migration.


πŸ“« Feedback & Issues

Found a bug? Have a feature request or usability suggestion?

Please open an issue here: Submit an issue

When submitting an issue, include the following if possible:

What you were trying to do

Any relevant command or flags used

Error output (with stack trace, if any)

Environment details (OS, Go version, PostgreSQL version)

We welcome all feedback β€” bug reports, questions, enhancements, and PRs!

Documentation ΒΆ

Overview ΒΆ

Copyright Β© 2025 Inskribe <inskribe@inskribestudio.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Directories ΒΆ

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL