Skip to content

Commit bc59735

Browse files
authored
Implement fixtures support (#241)
1 parent 438d8e9 commit bc59735

18 files changed

+641
-300
lines changed

.codeclimate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ exclude_patterns:
66
- "spec/"
77
- "!spec/support/helpers"
88
- "config/"
9-
- "src/alembic/"
9+
- "src/migrations/"
1010
- "db/"
1111
- "dist/"
1212
- "features/"

.idea/dataSources.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ RUN --mount=type=cache,target=~/.cache/uv \
6464
# Create the base app with the common python packages
6565
FROM base AS base_app
6666
USER nonroot
67-
COPY --chown=nonroot:nonroot src/alembic ./alembic
67+
COPY --chown=nonroot:nonroot src/migrations ./migrations
6868
COPY --chown=nonroot:nonroot src/domains ./domains
6969
COPY --chown=nonroot:nonroot src/gateways ./gateways
7070
COPY --chown=nonroot:nonroot src/common ./common

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ This template provides out of the box some commonly used functionalities:
2424
* Async tasks execution using [Dramatiq](https://dramatiq.io/index.html)
2525
* Repository pattern for databases using [SQLAlchemy](https://www.sqlalchemy.org/) and [SQLAlchemy bind manager](https://febus982.github.io/sqlalchemy-bind-manager/stable/)
2626
* Database migrations using [Alembic](https://alembic.sqlalchemy.org/en/latest/) (configured supporting both sync and async SQLAlchemy engines)
27+
* Database fixtures support using customized [Alembic](https://alembic.sqlalchemy.org/en/latest/) configuration
2728
* Authentication and Identity Provider using [ORY Zero Trust architecture](https://www.ory.sh/docs/kratos/guides/zero-trust-iap-proxy-identity-access-proxy)
2829
* Example CI/CD deployment pipeline for GitLab (The focus for this repository is still GitHub but, in case you want to use GitLab 🤷)
29-
* [TODO] Producer and consumer to emit and consume events using [CloudEvents](https://cloudevents.io/) format on [Confluent Kafka](https://docs.confluent.io/kafka-clients/python/current/overview.html)
30+
* [TODO] Producer and consumer to emit and consume events using [CloudEvents](https://cloudevents.io/) format using HTTP, to be used with [Knative Eventing](https://knative.dev/docs/eventing/)
3031

3132
## Documentation
3233

alembic.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[alembic]
44
# path to migration scripts
5-
script_location = src/alembic
5+
script_location = src/migrations
66

77
# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
88
# Uncomment the line below if you want the files to be prepended with date and time

docs/architecture.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ and the persistence layer.
1010

1111
This is a high level list of the packages in this application template:
1212

13-
* `alembic` (database migration manager)
13+
* `migrations` (database migration manager)
1414
* `dramatiq_worker` (async tasks runner)
1515
* `common` (some common boilerplate initialisation shared by all applications )
1616
* `http_app` (http presentation layer)
@@ -30,7 +30,7 @@ This is a high level representation of the nested layers in the application:
3030
```mermaid
3131
flowchart TD
3232
subgraph "Framework & Drivers + Interface Adapters"
33-
alembic
33+
migrations
3434
dramatiq_worker
3535
http_app
3636
gateways
@@ -51,7 +51,7 @@ flowchart TD
5151
end
5252
end
5353
54-
alembic ~~~ domains.books
54+
migrations ~~~ domains.books
5555
dramatiq_worker ~~~ domains.books
5656
http_app ~~~ domains.books
5757
gateways ~~~ domains.books

docs/packages/alembic.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
we implement some extra features on top of the default configuration:
55

66
* Support for both sync and async SQLAlchemy engines at the same time
7+
* Support for fixtures management
78
* Grabs the database information from the `SQLAlchemyBindManager` configuration
89
in the application, so we won't have duplicate configuration.
910
* `alembic.ini` (not technically part of the python package) is setup to

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ includes = ["src/**/*.py"]
7676
branch = true
7777
source = ["src"]
7878
omit = [
79-
"src/alembic/*",
79+
"src/migrations/*",
8080
"src/common/config.py",
8181
"src/common/logs/*",
8282
"src/dramatiq_worker/__init__.py",
@@ -94,7 +94,7 @@ exclude_also = [
9494

9595
[tool.mypy]
9696
files = ["src", "tests"]
97-
exclude = ["alembic"]
97+
exclude = ["migrations"]
9898
# Pydantic plugin causes some issues: https://github.com/pydantic/pydantic-settings/issues/403
9999
#plugins = "pydantic.mypy,strawberry.ext.mypy_plugin"
100100
plugins = "strawberry.ext.mypy_plugin"
@@ -151,3 +151,4 @@ ignore = [
151151
[tool.ruff.lint.per-file-ignores]
152152
"__init__.py" = ["F401"] # Ignore unused imports on init files
153153
"tests/**/*.py" = ["S101"] # Allow assert usage on tests
154+
"src/migrations/env.py" = ["E501"] # Allow long lines

src/alembic.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copy of alembic.ini used to run migrations inside the container
22

33
[alembic]
4-
script_location = alembic
4+
script_location = migrations
55
prepend_sys_path = .
66
file_template = %%(year)d-%%(month).2d-%%(day).2d-%%(hour).2d%%(minute).2d%%(second).2d-%%(rev)s_%%(slug)s
77
version_path_separator = os # Use os.pathsep. Default configuration used for new projects.

src/alembic/env.py

Lines changed: 0 additions & 187 deletions
This file was deleted.

0 commit comments

Comments
 (0)