immigrant-generator-postgres 0.2.0

Immigrant migrations generator for postgres SQL dialect
Documentation
!!!TEST views
scalar example = sql"INTEGER";
table Foo {
	example;
};
view Test = sql"""
	SELECT * FROM {Foo}
""";
// Also materialized
view.materialized TestMaterialized = sql"""
	SELECT * FROM {Foo}
""";
!!!UPDATE table changes will result in view metadata update
scalar example = sql"INTEGER";
table Foo {
	example "example2";
};
view Test = sql"""
	SELECT *, ({Foo.example} + 2) AS ex2 FROM {Foo}
""";
view.materialized TestMaterialized "newname" = sql"""
	SELECT * FROM {Foo}
	ORDER BY embedding <-> other_embedding
""";
!!!RESULT
-- updated: views --
CREATE DOMAIN example AS INTEGER;
CREATE TABLE foos (
	example example NOT NULL
);
CREATE VIEW tests AS
	SELECT * FROM foos
;
CREATE MATERIALIZED VIEW test_materializeds AS
	SELECT * FROM foos
;
COMMENT ON VIEW test_materializeds IS 'Also materialized';
-- updated: table changes will result in view metadata update --
ALTER VIEW tests RENAME TO moveaway_1;
ALTER MATERIALIZED VIEW test_materializeds RENAME TO moveaway_2;
ALTER TABLE foos RENAME COLUMN example TO example2;
DROP VIEW moveaway_1;
DROP MATERIALIZED VIEW moveaway_2;
CREATE VIEW tests AS
	SELECT *, (example2 + 2) AS ex2 FROM foos
;
CREATE MATERIALIZED VIEW newname AS
	SELECT * FROM foos
	ORDER BY embedding <-> other_embedding
;
-- updated: cleanup schema changes --
DROP VIEW tests;
DROP MATERIALIZED VIEW newname;
DROP TABLE foos;
DROP DOMAIN example;