PGFINE_CONNECTION_STRING
credentials for altering target dbPGFINE_ADMIN_CONNECTION_STRING
credentials for creating a new database (usually postgres db with user postgres) refereced above.PGFINE_DIR
defaults to ./pgfine
Connection strings: https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING
pgfine
pgfine
is not yet published at crates.io so you should install it from git repository:
bash
git clone https://gitlab.com/mrsk/pgfine
cargo install --path ./pgfine
env-local-db-0.sh
(as an example) file like this:```bash export PGFINECONNECTIONSTRING="..." export PGFINEADMINCONNECTION_STRING="..."
``
- Run
pgfine init
- Modify newly created
./pgfine/create.sql` if needed.
./pgfine/create/*
scripts if needed.bash
source env-local-db-0.sh
pgfine migrate
./pgfine/**/*.sql
../pgfine/migrations/*
scripts../pgfine/views/public.view0.sql
)<schema>.<name>.sql
.Setup environment and run
bash
source env-local-db-0.sh
pgfine migrate
Test your fresh db maybe.
Table constraints should be stored along with tables. You will have a problem if constraints form circular dependencies.
pgfine init [./pgfine]
./pgfine/create.sql
example script.pgfine create
PGFINE_CONNECTION_STRING
credentials.pgfine_objects
and pgfine_migrations
tabls are created in default schema with the last migration_id and object hashes.pgfine migrate
PGFINE_ADMIN_CONNECTION_STRING
to create a new database and role referenced in PGFINE_CONNECTION_STRING
using /pgfine/create/*.sql
scripts (if they do not exist).PGFINE_CONNECTION_STRING
credentials to connect to a working database../pgfine/migrations/
and updates version in pgfine
table. (This is skipped if the database is newly created)../pgfine/
and builds the dependency tree.pgfine
table (or drop the object if it was deleted).pgfine_objects
table with newest information.pgfine_migrations
executed migration scripts.pgfine drop --no-joke
PGFINE_ADMIN_CONNECTION_STRING
credentials to connect to database./pgfine/drop/*.sql
scripts to drop database and role../pgfine/create/
./pgfine/drop/
./pgfine/tables/
./pgfine/views/
./pgfine/functions/
./pgfine/roles/
./pgfine/migrations/
pgfine_objects
tableContains a list of managed pgfine objects and their hashes.
pgfine_migrations
tableContains a list of executed migrations. Selecting the max value should reveal the current state of database.
tables
, views
and functions
correspond to database object. This information is used to track dependencies between objects (using simple text match)./pgfine/migrations/
has format <comparable_version_string>.*
object_md5
will be updated. (online if possible)Scripts are modified during pgfine migrate
execution
CREATE OR REPLACE
. If it fails and --offline
flag is provided we do DROP
and CREATE
including all the dependencies.does not support functions with same name different args.
pgfine init
pgfine drop
pgfine migrate
./pgfine/constraints
)./example/