Skip to content

pagreczner/walter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Walter is a utility to quickly generate PostgreSQL type change migrations.

Install

go get github.com/pagreczner/walter

Usage

walter <type_name> <table_name> <col_name> [...enum_values]

Usage without Enum's passed in.

$ walter my_type some_table potato

ALTER TYPE my_type RENAME TO __my_type;
CREATE TYPE my_type AS ENUM();

ALTER TABLE some_table RENAME COLUMN potato to _potato;
ALTER TABLE some_table ADD potato my_type NOT NULL DEFAULT '';
UPDATE some_table SET potato = _potato::text::my_type;
ALTER TABLE some_table DROP COLUMN _potato;
DROP TYPE __my_type;

Usage With Enum's

$ walter my_type some_table potato ONE TWO THREE

ALTER TYPE my_type RENAME TO __my_type;
CREATE TYPE my_type AS ENUM('ONE','TWO','THREE');

ALTER TABLE some_table RENAME COLUMN potato to _potato;
ALTER TABLE some_table ADD potato my_type NOT NULL DEFAULT 'ONE';
UPDATE some_table SET potato = _potato::text::my_type;
ALTER TABLE some_table DROP COLUMN _potato;
DROP TYPE __my_type;

About

Produces PostgreSQL type migration sql.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages