sql-up

module
v0.0.0-...-2cc4437 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2025 License: Apache-2.0

README

sql-up

Always forward schema migration because you cannot just rollback in production.

Usage

sql-up --dbms postgres --connection-string <connection-string> --sql-file <sql-file>

sql-up will apply the migration after lasted-non applied magic marker -- sql-up in the SQL file.

-- sql-up
-- Create table
CREATE TABLE users (
  id SERIAL PRIMARY KEY,
  name TEXT NOT NULL
);

-- sql-up
ALTER TABLE users ADD COLUMN email TEXT NULL;

-- sql-up
ALTER TABLE users ADD COLUMN address TEXT NULL;

sql-up does that by creating a new table sql_up in the database to store the last applied file content and compare with the input file content to determine the migration. This mean the SQL file must be append-only.

Supported Databases and Connection String

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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