postcar
Table of Contents
Installation
pip install postcar
License
postcar is distributed under the terms of the Apache-2.0 license.
Usage
Migrations
Migration packages
Each migration package needs to be importable. Migration modules must be named starting with a four digit sequence number, followed by an underscore, and a (short) description.
Here's a sample structure of a migration directory:
migrations
├── __init__.py
├── 0001_init.py
├── 0002_authorization.py
└── 0003_create_extensions.py
Migration modules
The migration modules must contain a class named Migration,
which must inherit from postcar.Migration.
A minimal migration file might look as follows:
import postcar
class Migration(postcar.Migration):
def get_forward(self) -> str:
return """
create extension pg_trgm;
"""
def get_rollback(self) -> str:
return """
drop extension pg_trgm;
"""
CLI
The package comes with a minimal CLI.
See postcar --help for available commands.
Configuration
NOTE: this isn't implemented yet, so use the CLI for the time being
Sample configuration file:
# postcar.conf.py
import os
from postcar import config
connection = config.ConnectionInfo(
host="127.0.0.1",
port=5432,
dbname="mydb",
username="postcar",
password=os.getenv("POSTGRES_PASSWORD"),
)
namespace = "_bookkeeping"
packages = ["myapp.migrations"]
Configuration parameters
The below table is an exhaustive list of the available parameters. More detailed descriptions below the table.
| Name | CLI | Type | Default |
|---|---|---|---|
| — | -c/--conf |
Optional[str] |
None |
connection.host |
-H/--host |
Optional[str] |
None |
connection.port |
-p/--port |
Optional[int] |
None |
connection.dbname |
-D/--dbname |
Optional[str] |
None |
connection.username |
-U/--user |
Optional[str] |
None |
connection.password |
-P/--password |
Optional[str] |
None |
namespace |
-s/--namespace |
str |
"_postcar" |
packages |
— | Sequence[str] |
() |
connection.[x]
Connection info parameters, very similar to the Postgres defaults.
namespace
The database schema to use for bookkeeping.
packages
The migration packages to run migrations for by default.
Development
Internal migrations
For the sake of consistency, and keeping things "simple",
internal schema migrations are designated by minor versions.
In short, a bump from 1.2.3 to 1.2.4 must never migrate the internal schema,
whereas 1.2.3 to 1.3.0 or 2.0.0 may.
Ultimately, the goal is to enable effortless upgrades between versions, without unnecessarily complicated manual intervention.
Regardless: this is a rather experimental package, at least until version 1.0.0. Until then: expect things to break, without any guarantees.
TODO
- Implement rollback
- Migration dependencies
- CLI command for generating a new migration skeleton
Metadata
Release files for postcar 0.0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| postcar-0.0.9.tar.gz | 13.6 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| postcar-0.0.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.3 kB
Release files / postcar-0.0.9.tar.gz
| Download URL | postcar-0.0.9.tar.gz |
|---|---|
| Size | 13.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cd020389d62b32d4b83b8c91ae6d81a570f64782d394ecc5c82fbef2d64a5453
|
|
BLAKE2b-256 checksum How to use checksums |
f29994266eb1275151aab8bd428b4d24c7a59fdc04c0f6bcaf8bdc84afd3a07c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 18, 2024.
Transparency logRelease files / postcar-0.0.9-py3-none-any.whl
| Download URL | postcar-0.0.9-py3-none-any.whl |
|---|---|
| Size | 18.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c9f13b26439ea344ec0004e947ec6047b837853bb84b547af2584823a5cfad78
|
|
BLAKE2b-256 checksum How to use checksums |
25ad4ea286a99373a5f2b96461b4a2940fe2f3f55291ca24821016628625b35a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 18, 2024.
Transparency logSecurity for postcar 0.0.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for postcar-0.0.9.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 18, 2024.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.