Postgres Migrations
When aerich or alembic auto-generated migration files aren’t enough.
Summary of the basic DDL/DML statements used to keep track of the Postrges DB migrations, followed by a couple of use cases.
General DDL / DML CREATE / INSERT CREATE EXTENSION IF NOT EXISTS postgis; CREATE INDEX location_gidx ON product USING gist (location); CREATE UNIQUE INDEX product_name_supplier_uidx ON product (name, supplier); CREATE TYPE orderstatus AS ENUM('PROCESSED', 'SHIPPED', 'DELIVERED', 'CANCELLED'); -- upsert INSERT INTO product (name, supplier_id, location, status) VALUES ('NOTEBOOK-A6', 'Muji', ST_GeomFromText('POINT(12.