Skip to content

Commit 57c7cb8

Browse files
authored
Use unique short id in invoices migration (#889)
## Description ### Summary <!--Brief description of what this PR does.--> <!--Don't explain the code, justify what this PR exists for!--> <!--Sources/references at the end--> ### Issues to be resolved <!-- If applicable--> <!--Use keywords "closes", "fixes", "resolves", or others at https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests --> <!--Fixes #--> <!--Fixes aeecleclair/CalypSSO#--> ### Required PRs <!-- If applicable--> <!--Use keywords "depends on" or "blocked by", see https://github.com/gregsdennis/dependencies-action --> <!--Depends on #--> <!--Depends on aeecleclair/CalypSSO#--> ### Changes Made <!--Please describe the changes made in this pull request--> <!--Tell the big steps, use a checklist to show progress. You can explain here how the code works.--> - [x] ... - [ ] ... ### Additional Notes <!--Anything relevant that does not quite fit in the summary--> <details> <summary> ## Classification </summary> ### Type of Change - [ ] 🐛 Bug fix (non-breaking change which fixes an issue) - [ ] ✨ New feature (non-breaking change which adds functionality) - [ ] 🔨 Refactor (non-breaking change that neither fixes a bug nor adds a feature) - [ ] 🔧 Infra CI/CD (changes to configs of workflows) - [ ] 💥 BREAKING CHANGE (fix or feature that require a new minimal version of the front-end) - [ ] 😶‍🌫️ No impact for the end-users ### Impact & Scope - [ ] Core functionality changes - [ ] Single module changes - [ ] Multiple modules changes - [ ] Database migrations required - [ ] Other: <!--not module-oriented--> ### Testing - [ ] 1. Tested this locally - [ ] 2. Added/modified tests that pass the CI - [ ] 3. Tested in a pre-prod - [ ] 0. Untestable (exceptionally), will be tested in prod directly ### Documentation - [ ] Updated [the docs](docs.myecl.fr) accordingly : <!--[Docs#0 - Title](https://github.com/aeecleclair/myecl-documentation/pull/0)--> - [ ] `"` Docstrings - [ ] `#` Inline comments - [ ] No documentation needed </details>
1 parent 157257d commit 57c7cb8

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

migrations/versions/44-myeclpay_invoices.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ def upgrade() -> None:
128128
structure_table,
129129
).values(
130130
{
131-
"short_id": "ABC",
132131
"siege_address_street": "To change",
133132
"siege_address_city": "To change",
134133
"siege_address_zipcode": "To change",
@@ -140,6 +139,23 @@ def upgrade() -> None:
140139
},
141140
),
142141
)
142+
structures = conn.execute(
143+
sa.select(structure_table.c.id),
144+
).all()
145+
for idx, (structure_id,) in enumerate(structures):
146+
conn.execute(
147+
sa.update(
148+
structure_table,
149+
)
150+
.where(
151+
structure_table.c.id == structure_id,
152+
)
153+
.values(
154+
{
155+
"short_id": f"{idx + 1:03d}",
156+
},
157+
),
158+
)
143159
conn.execute(
144160
sa.update(
145161
store_table,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authors = [{ name = "AEECL ECLAIR" }]
66

77
# Hyperion follows Semantic Versioning
88
# https://semver.org/
9-
version = "4.10.1"
9+
version = "4.10.2"
1010
minimal-titan-version-code = 139
1111
requires-python = ">= 3.11, < 3.13"
1212

0 commit comments

Comments
 (0)