pogo-core 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. pogo_core-0.1.0/.github/pull_request_template.md +26 -0
  2. pogo_core-0.1.0/.github/workflows/publish.yml +28 -0
  3. pogo_core-0.1.0/.github/workflows/style.yml +35 -0
  4. pogo_core-0.1.0/.github/workflows/tests.yml +97 -0
  5. pogo_core-0.1.0/.gitignore +2 -0
  6. pogo_core-0.1.0/.pre-commit-config.yaml +31 -0
  7. pogo_core-0.1.0/CHANGELOG.md +11 -0
  8. pogo_core-0.1.0/PKG-INFO +80 -0
  9. pogo_core-0.1.0/README.md +40 -0
  10. pogo_core-0.1.0/_typos.toml +8 -0
  11. pogo_core-0.1.0/codecov.yml +4 -0
  12. pogo_core-0.1.0/pyproject.toml +152 -0
  13. pogo_core-0.1.0/src/pogo_core/__init__.py +0 -0
  14. pogo_core-0.1.0/src/pogo_core/error.py +1 -0
  15. pogo_core-0.1.0/src/pogo_core/migration.py +205 -0
  16. pogo_core-0.1.0/src/pogo_core/py.typed +0 -0
  17. pogo_core-0.1.0/src/pogo_core/squash.py +203 -0
  18. pogo_core-0.1.0/src/pogo_core/types.py +15 -0
  19. pogo_core-0.1.0/src/pogo_core/util/__init__.py +0 -0
  20. pogo_core-0.1.0/src/pogo_core/util/migrate.py +82 -0
  21. pogo_core-0.1.0/src/pogo_core/util/sql.py +91 -0
  22. pogo_core-0.1.0/src/pogo_core/util/testing.py +36 -0
  23. pogo_core-0.1.0/src/pogo_core/util/topologicalsort.py +87 -0
  24. pogo_core-0.1.0/tasks.py +55 -0
  25. pogo_core-0.1.0/tests/__init__.py +0 -0
  26. pogo_core-0.1.0/tests/conftest.py +70 -0
  27. pogo_core-0.1.0/tests/test_migration.py +742 -0
  28. pogo_core-0.1.0/tests/test_squash.py +623 -0
  29. pogo_core-0.1.0/tests/util/__init__.py +0 -0
  30. pogo_core-0.1.0/tests/util/test_migrate.py +155 -0
  31. pogo_core-0.1.0/tests/util/test_sql.py +77 -0
  32. pogo_core-0.1.0/tests/util/test_testing.py +61 -0
  33. pogo_core-0.1.0/tests/util/test_topological_sort.py +70 -0
  34. pogo_core-0.1.0/unittest-compose.yml +18 -0
  35. pogo_core-0.1.0/uv.lock +1276 -0
@@ -0,0 +1,26 @@
1
+ # Set a conventional commit style topic
2
+
3
+ ```
4
+ <type>[(optional scope)][!]: <description>
5
+ ```
6
+
7
+ feat: what new feature was added
8
+ feat!: what breaking change was made
9
+ feat(scope): change to scope
10
+
11
+ # Replace this description with additional information to be included in merge commit
12
+
13
+ [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)
14
+
15
+ ```
16
+ [optional body]
17
+
18
+ [optional footer(s)]
19
+ ```
20
+
21
+ ```
22
+ More details about the change.
23
+
24
+ BREAKING CHANGE:
25
+ Refs: #{issue}
26
+ ```
@@ -0,0 +1,28 @@
1
+ name: Publish
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ publish:
9
+ runs-on: ubuntu-latest
10
+
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+
14
+ - name: Set up Python 3.9
15
+ uses: actions/setup-python@v5
16
+ with:
17
+ python-version: "3.9.x"
18
+
19
+ - name: Install uv
20
+ uses: astral-sh/setup-uv@v2
21
+
22
+ - name: Publish
23
+ env:
24
+ TWINE_USERNAME: __token__
25
+ TWINE_PASSWORD: ${{ secrets.PYPI_PUBLISH_TOKEN }}
26
+ run: |
27
+ uv build
28
+ uvx twine upload dist/*
@@ -0,0 +1,35 @@
1
+ name: Style
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ # Push will only build on branches that match this name
7
+ # Pull requests will override this, so pushes to pull requests will still build
8
+ - main
9
+ pull_request:
10
+ branches:
11
+ - main
12
+
13
+ jobs:
14
+ check-style:
15
+
16
+ runs-on: ubuntu-latest
17
+
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+
21
+ - name: Set up Python 3.11
22
+ uses: actions/setup-python@v5
23
+ with:
24
+ python-version: "3.11.x"
25
+
26
+ - name: Install uv
27
+ uses: astral-sh/setup-uv@v2
28
+
29
+ - name: Install dependencies
30
+ run: |
31
+ uv sync --all-extras
32
+
33
+ - name: Lint with ruff
34
+ run: |
35
+ uv run pre-commit run --all-files
@@ -0,0 +1,97 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ # Push will only build on branches that match this name
7
+ # Pull requests will override this, so pushes to pull requests will still build
8
+ - main
9
+ pull_request:
10
+ branches:
11
+ - main
12
+
13
+ jobs:
14
+
15
+ test-coverage:
16
+
17
+ runs-on: ubuntu-latest
18
+
19
+ services:
20
+ postgres:
21
+ image: postgres:14
22
+ env:
23
+ POSTGRES_USER: unit
24
+ POSTGRES_PASSWORD: password
25
+ POSTGRES_DB: unit
26
+ ports:
27
+ - 5432:5432
28
+ options: >-
29
+ --health-cmd pg_isready
30
+ --health-interval 10s
31
+ --health-timeout 5s
32
+ --health-retries 3
33
+
34
+ steps:
35
+ - uses: actions/checkout@v3
36
+ - name: Set up Python 3.9
37
+ uses: actions/setup-python@v3
38
+ with:
39
+ python-version: "3.9.x"
40
+
41
+ - name: Install uv
42
+ uses: astral-sh/setup-uv@v2
43
+
44
+ - name: Install dependencies
45
+ run: uv sync --all-extras
46
+
47
+ - name: Generate coverage report
48
+ env:
49
+ POSTGRES_DSN: postgres://unit:password@localhost:5432/unit
50
+ run: |
51
+ uv run pytest --cov=src/pogo_core --cov-report=xml
52
+
53
+ - name: Upload coverage to Codecov
54
+ uses: codecov/codecov-action@v1
55
+ with:
56
+ token: ${{ secrets.CODECOV_TOKEN }}
57
+ slug: NRWLDev/pogo-core
58
+ file: ./coverage.xml
59
+ flags: unittests
60
+ name: codecov-umbrella
61
+ yml: ./codecov.yml
62
+ fail_ci_if_error: false
63
+
64
+ test-python-versions:
65
+
66
+ runs-on: ${{ matrix.os }}
67
+
68
+ strategy:
69
+ matrix:
70
+ os: [ubuntu-latest, macos-latest, windows-latest]
71
+ version: ["3.9.x", "3.10.x", "3.11.x", "3.12.x"]
72
+
73
+ steps:
74
+ - uses: ikalnytskyi/action-setup-postgres@v8
75
+ with:
76
+ username: unit
77
+ password: password
78
+ database: unit
79
+ port: 5432
80
+ id: postgres
81
+ - uses: actions/checkout@v3
82
+ - name: Set up Python ${{ matrix.version }}
83
+ uses: actions/setup-python@v3
84
+ with:
85
+ python-version: ${{ matrix.version }}
86
+
87
+ - name: Install uv
88
+ uses: astral-sh/setup-uv@v2
89
+
90
+ - name: Install dependencies
91
+ run: uv sync --all-extras
92
+
93
+ - name: Test with pytest
94
+ env:
95
+ POSTGRES_DSN: postgres://unit:password@localhost:5432/unit
96
+ run: |
97
+ uv run pytest
@@ -0,0 +1,2 @@
1
+ dist/*
2
+ .coverage
@@ -0,0 +1,31 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v4.4.0
4
+ hooks:
5
+ - id: trailing-whitespace
6
+ - id: check-added-large-files
7
+ - id: check-ast
8
+ - id: check-json
9
+ - id: check-toml
10
+ - id: fix-byte-order-marker
11
+ - id: end-of-file-fixer
12
+
13
+ - repo: https://github.com/crate-ci/typos
14
+ rev: v1.24.5
15
+ hooks:
16
+ - id: typos
17
+ args: [--force-exclude]
18
+
19
+ - repo: https://github.com/astral-sh/ruff-pre-commit
20
+ rev: v0.14.10
21
+ hooks:
22
+ - id: ruff-format
23
+ args: [--preview, -s]
24
+ - id: ruff
25
+ args: [--fix]
26
+
27
+ - repo: https://github.com/Lucas-C/pre-commit-hooks
28
+ rev: v1.3.1
29
+ hooks:
30
+ - id: remove-crlf
31
+ - id: remove-tabs
@@ -0,0 +1,11 @@
1
+ # Changelog
2
+
3
+ ## v0.1.0 (released 2026-01-10)
4
+
5
+ ### Features and Improvements
6
+
7
+ - **Breaking** Extract core library functionality out of pogo-migrate. [[9a00ead](https://github.com/NRWLDev/pogo-core/commit/9a00ead4e35833263e9f354d197e6235a1a4da37)]
8
+
9
+ ### Miscellaneous
10
+
11
+ - Improve test coverage. [[a11d7c2](https://github.com/NRWLDev/pogo-core/commit/a11d7c2c38769335d60a2cd6e052a6aa33c21aa4)]
@@ -0,0 +1,80 @@
1
+ Metadata-Version: 2.4
2
+ Name: pogo-core
3
+ Version: 0.1.0
4
+ Summary: Database migration tool for asyncpg
5
+ Project-URL: homepage, https://github.com/NRWLDev/pogo-core
6
+ Project-URL: documentation, https://nrwldev.github.io/pogo-core/
7
+ Author-email: Daniel Edgecombe <daniel@nrwl.co>
8
+ Maintainer-email: Daniel Edgecombe <daniel@nrwl.co>
9
+ License-Expression: Apache-2.0
10
+ Keywords: asyncpg,database,migrate,migrations,yoyo
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Topic :: Database
24
+ Classifier: Topic :: Software Development
25
+ Requires-Python: >=3.9
26
+ Requires-Dist: sqlglot>=25.19
27
+ Requires-Dist: sqlparse==0.5.2
28
+ Provides-Extra: dev
29
+ Requires-Dist: asyncpg>=0.29.0; extra == 'dev'
30
+ Requires-Dist: changelog-gen>=0.12; extra == 'dev'
31
+ Requires-Dist: pre-commit>=3.0.2; extra == 'dev'
32
+ Requires-Dist: pytest-asyncio>=0.23.5; extra == 'dev'
33
+ Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
34
+ Requires-Dist: pytest-env>=0.8.1; extra == 'dev'
35
+ Requires-Dist: pytest-random-order>=1.1.1; extra == 'dev'
36
+ Requires-Dist: pytest>=8.0.2; extra == 'dev'
37
+ Requires-Dist: ruff>=0.6.4; extra == 'dev'
38
+ Requires-Dist: ty>=0.0.4; extra == 'dev'
39
+ Description-Content-Type: text/markdown
40
+
41
+ # Pogo migrate core - asyncpg migration tooling
42
+ [![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)
43
+ [![ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
44
+ [![image](https://img.shields.io/pypi/v/pogo_core.svg)](https://pypi.org/project/pogo_core/)
45
+ [![image](https://img.shields.io/pypi/l/pogo_core.svg)](https://pypi.org/project/pogo_core/)
46
+ [![image](https://img.shields.io/pypi/pyversions/pogo_core.svg)](https://pypi.org/project/pogo_core/)
47
+ ![style](https://github.com/NRWLDev/pogo-core/actions/workflows/style.yml/badge.svg)
48
+ ![tests](https://github.com/NRWLDev/pogo-core/actions/workflows/tests.yml/badge.svg)
49
+ [![codecov](https://codecov.io/gh/NRWLDev/pogo-core/branch/main/graph/badge.svg)](https://codecov.io/gh/NRWLDev/pogo-core)
50
+
51
+ `pogo-core` is a migration tool intended for use with `asyncpg` and assists
52
+ with maintaining your database schema (and data if required) as it evolves.
53
+ Pogo supports migrations written in raw sql, as well as python files (useful
54
+ when data needs to be migrated).
55
+
56
+ A migration can be as simple as:
57
+
58
+ ```sql
59
+ -- a descriptive message
60
+ -- depends: 20210101_01_abcdef-previous-migration
61
+
62
+ -- migrate: apply
63
+ CREATE TABLE foo (id INT, bar VARCHAR(20), PRIMARY KEY (id));
64
+
65
+ -- migrate: rollback
66
+ DROP TABLE foo;
67
+ ```
68
+
69
+ Pogo manages these migration scripts and provides utility functions to apply
70
+ and rollback migrations.
71
+
72
+ For a user interface, install `pogo-migrate` instead.
73
+
74
+ See the [docs](https://nrwldev.github.io/pogo-migrate/) for more details.
75
+
76
+ ## Thanks and Credit
77
+
78
+ Inspiration for this tool is drawn from
79
+ [yoyo](https://ollycope.com/software/yoyo/latest/) and
80
+ [dbmate](https://github.com/amacneil/dbmate).
@@ -0,0 +1,40 @@
1
+ # Pogo migrate core - asyncpg migration tooling
2
+ [![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)
3
+ [![ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
4
+ [![image](https://img.shields.io/pypi/v/pogo_core.svg)](https://pypi.org/project/pogo_core/)
5
+ [![image](https://img.shields.io/pypi/l/pogo_core.svg)](https://pypi.org/project/pogo_core/)
6
+ [![image](https://img.shields.io/pypi/pyversions/pogo_core.svg)](https://pypi.org/project/pogo_core/)
7
+ ![style](https://github.com/NRWLDev/pogo-core/actions/workflows/style.yml/badge.svg)
8
+ ![tests](https://github.com/NRWLDev/pogo-core/actions/workflows/tests.yml/badge.svg)
9
+ [![codecov](https://codecov.io/gh/NRWLDev/pogo-core/branch/main/graph/badge.svg)](https://codecov.io/gh/NRWLDev/pogo-core)
10
+
11
+ `pogo-core` is a migration tool intended for use with `asyncpg` and assists
12
+ with maintaining your database schema (and data if required) as it evolves.
13
+ Pogo supports migrations written in raw sql, as well as python files (useful
14
+ when data needs to be migrated).
15
+
16
+ A migration can be as simple as:
17
+
18
+ ```sql
19
+ -- a descriptive message
20
+ -- depends: 20210101_01_abcdef-previous-migration
21
+
22
+ -- migrate: apply
23
+ CREATE TABLE foo (id INT, bar VARCHAR(20), PRIMARY KEY (id));
24
+
25
+ -- migrate: rollback
26
+ DROP TABLE foo;
27
+ ```
28
+
29
+ Pogo manages these migration scripts and provides utility functions to apply
30
+ and rollback migrations.
31
+
32
+ For a user interface, install `pogo-migrate` instead.
33
+
34
+ See the [docs](https://nrwldev.github.io/pogo-migrate/) for more details.
35
+
36
+ ## Thanks and Credit
37
+
38
+ Inspiration for this tool is drawn from
39
+ [yoyo](https://ollycope.com/software/yoyo/latest/) and
40
+ [dbmate](https://github.com/amacneil/dbmate).
@@ -0,0 +1,8 @@
1
+ [default]
2
+ extend-ignore-re = [
3
+ '\[[0-9a-fA-F]{7}\]',
4
+ '.*# pragma: no-spell-check',
5
+ ]
6
+
7
+ [files]
8
+ extend-exclude = ["CHANGELOG.md"]
@@ -0,0 +1,4 @@
1
+ coverage:
2
+ precision: 2
3
+ round: down
4
+ range: "95...100"
@@ -0,0 +1,152 @@
1
+ [project]
2
+ name = "pogo-core"
3
+ version = "0.1.0"
4
+ description = "Database migration tool for asyncpg"
5
+ readme = "README.md"
6
+ authors = [
7
+ {name = "Daniel Edgecombe", email = "daniel@nrwl.co"},
8
+ ]
9
+ maintainers = [
10
+ {name = "Daniel Edgecombe", email = "daniel@nrwl.co"},
11
+ ]
12
+ license = "Apache-2.0"
13
+ requires-python = ">=3.9"
14
+ keywords = ["migrations", "migrate", "database", "asyncpg", "yoyo"]
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Environment :: Console",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: Apache Software License",
20
+ "Operating System :: OS Independent",
21
+ "Topic :: Database",
22
+ "Topic :: Software Development",
23
+ "Programming Language :: Python",
24
+ "Programming Language :: Python :: 3 :: Only",
25
+ "Programming Language :: Python :: 3.9",
26
+ "Programming Language :: Python :: 3.10",
27
+ "Programming Language :: Python :: 3.11",
28
+ "Programming Language :: Python :: 3.12",
29
+ "Programming Language :: Python :: 3",
30
+ ]
31
+
32
+ dependencies = [
33
+ "sqlparse == 0.5.2",
34
+ "sqlglot >= 25.19",
35
+ ]
36
+
37
+ [project.urls]
38
+ homepage = "https://github.com/NRWLDev/pogo-core"
39
+ documentation = "https://nrwldev.github.io/pogo-core/"
40
+
41
+ [project.optional-dependencies]
42
+ dev = [
43
+ # Tests
44
+ "asyncpg >= 0.29.0",
45
+ "pytest-asyncio >= 0.23.5",
46
+ "pytest >= 8.0.2",
47
+ "pytest-random-order >= 1.1.1",
48
+ "pytest-cov >= 4.1.0",
49
+ "pytest-env >= 0.8.1",
50
+
51
+ # Style
52
+ "ruff >= 0.6.4",
53
+ "pre-commit >= 3.0.2",
54
+ "ty >= 0.0.4",
55
+
56
+ # release
57
+ "changelog-gen >= 0.12",
58
+ ]
59
+
60
+ [tool.changelog_gen]
61
+ current_version = "0.1.0"
62
+ reject_empty = true
63
+ allowed_branches = [
64
+ "main",
65
+ ]
66
+ date_format = "(released %Y-%m-%d)"
67
+
68
+ [tool.changelog_gen.github]
69
+ strip_pr_from_description = true
70
+ extract_pr_from_description = true
71
+ extract_common_footers = true
72
+
73
+ [[tool.changelog_gen.extractors]]
74
+ footer = ["closes", "fixes", "Refs"]
75
+ pattern = '#(?P<issue_ref>\d+)'
76
+
77
+ [[tool.changelog_gen.link_generators]]
78
+ source = "issue_ref"
79
+ link = "https://github.com/NRWLDev/pogo-core/issues/{0}"
80
+
81
+ [[tool.changelog_gen.link_generators]]
82
+ source = "__change__"
83
+ text = "{0.short_hash}"
84
+ link = "https://github.com/NRWLDev/pogo-core/commit/{0.commit_hash}"
85
+
86
+ [[tool.changelog_gen.files]]
87
+ filename = "pyproject.toml"
88
+ pattern = 'version = "{version}"'
89
+
90
+ [tool.pytest.ini_options]
91
+ asyncio_mode = "auto"
92
+ testpaths = ["tests"]
93
+ addopts = [
94
+ "--random-order",
95
+ "-p no:logging",
96
+ ]
97
+ env = [
98
+ "D:POSTGRES_DSN=postgres://unit:password@localhost:5435/unit",
99
+ ]
100
+ markers = ["nosync: mark a test to not run pogo_ensure_sync helper"]
101
+
102
+ [tool.coverage.report]
103
+ sort = "cover"
104
+ fail_under = 95
105
+ show_missing = true
106
+ skip_covered = true
107
+ exclude_lines = [
108
+ "# pragma: no cover",
109
+ "if t.TYPE_CHECKING:",
110
+ "class .*\\btyping.Protocol\\):",
111
+ "class .*\\bProtocol\\):",
112
+ ]
113
+
114
+ [tool.coverage.run]
115
+ branch = true
116
+ source = ["src/pogo_core"]
117
+
118
+ [tool.ruff]
119
+ target-version = "py39"
120
+ line-length = 120
121
+ output-format = "concise"
122
+
123
+ [tool.ruff.lint]
124
+ select = ["ALL"]
125
+ ignore = [
126
+ "D",
127
+ "FIX",
128
+ "TD003",
129
+ "ERA",
130
+ "E501", # Handled by ruff format
131
+ ]
132
+
133
+ [tool.ruff.lint.per-file-ignores]
134
+ "tasks.py" = ["ANN", "E501", "INP001", "S"]
135
+ "tests/*" = ["ANN", "D", "S105", "S106", "SLF", "DTZ005", "S101", "S608", "TD", "PLR0913"]
136
+
137
+ [tool.ruff.format]
138
+ line-ending = "lf"
139
+ quote-style = "double"
140
+
141
+ [tool.ruff.lint.flake8-quotes]
142
+ docstring-quotes = "double"
143
+
144
+ [tool.ruff.lint.isort]
145
+ known-first-party = ["pogo_core"]
146
+
147
+ [tool.ruff.lint.pydocstyle]
148
+ convention = "google"
149
+
150
+ [build-system]
151
+ requires = ["hatchling"]
152
+ build-backend = "hatchling.build"
File without changes
@@ -0,0 +1 @@
1
+ class BadMigrationError(Exception): ...