xync-db 0.2.1__tar.gz → 0.2.2.dev17__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.
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/PKG-INFO +1 -1
- xync_db-0.2.2.dev17/src/xync_db/migrations/models/0005_credex_del.py +40 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/models/__init__.py +8 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/.gitignore +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/README.md +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/pyproject.toml +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/__init__.py +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/config.py +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/enums.py +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/exceptions.py +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/graph.py +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/i18n.py +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/logo.png +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/migrations/CLAUDE.md +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/migrations/__init__.py +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/migrations/models/0001_initial.py +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/migrations/models/0002_triggers.py +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/migrations/models/0003_files_seed.py +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/migrations/models/0004_all_seed.py +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/migrations/models/__init__.py +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/migrations/models/seed/__init__.py +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/migrations/models/seed/a_actor_seed.py +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/migrations/models/seed/a_tg_seed.py +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/migrations/models/seed/b_htx_seed.py +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/migrations/models/seed/xync_files.sql +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/models/CLAUDE.md +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/py.typed +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/shared.py +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/typs/__init__.py +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/typs/db/__init__.py +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/typs/db/actor.py +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/typs/db/ad.py +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/typs/db/common.py +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/typs/db/cred.py +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/typs/db/order.py +0 -0
- {xync_db-0.2.1 → xync_db-0.2.2.dev17}/src/xync_db/typs/db/pm.py +0 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""Per-CredEx delete trigger → `credexs_del` channel.
|
|
2
|
+
|
|
3
|
+
Lets a user unregister ONE credential from ONE exchange (settings/creds edit form): deleting a
|
|
4
|
+
single `credex` row reactively removes it from that exchange (mirror of `credexs_new`, which posts
|
|
5
|
+
a freshly inserted `CredEx(exid=0)`). The handler is `api.handlers.creds.credex_del`.
|
|
6
|
+
|
|
7
|
+
The default `plsql("credex")` DEL trigger (from 0002) only carried `OLD.id`, useless post-cascade.
|
|
8
|
+
We override it: emit `[person_id, ex_id, exid]` (person via the still-living parent `cred`) — exactly
|
|
9
|
+
what the handler needs to find the agent and call `acl.cred_del(exid)`.
|
|
10
|
+
|
|
11
|
+
Crucially we SKIP the notify when the parent `cred` is already gone: that's a `Cred` cascade-delete,
|
|
12
|
+
where the BEFORE-DELETE `cred_del()` trigger already snapshotted every credex into `creds_del`. Firing
|
|
13
|
+
here too would double-delete on the exchange. A standalone credex delete leaves the cred alive → notify.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from typing import ClassVar
|
|
17
|
+
|
|
18
|
+
from tortoise.migrations.migration import Migration as BaseMigration
|
|
19
|
+
from tortoise.migrations.operations import RunSQL
|
|
20
|
+
|
|
21
|
+
CREDEX_DEL_SQL = """
|
|
22
|
+
CREATE OR REPLACE FUNCTION credex_del() returns trigger as $credex_del_trg$
|
|
23
|
+
DECLARE
|
|
24
|
+
pid INT;
|
|
25
|
+
BEGIN
|
|
26
|
+
-- person via the parent cred; NULL ⇒ cred already cascade-deleted ⇒ cred_del() handled it ⇒ skip
|
|
27
|
+
SELECT person_id INTO pid FROM cred WHERE id = OLD.cred_id;
|
|
28
|
+
IF pid IS NOT NULL THEN
|
|
29
|
+
PERFORM pg_notify('credexs_del', jsonb_build_array(pid, OLD.ex_id, OLD.exid)::varchar);
|
|
30
|
+
END IF;
|
|
31
|
+
RETURN NULL;
|
|
32
|
+
END
|
|
33
|
+
$credex_del_trg$ LANGUAGE plpgsql;
|
|
34
|
+
CREATE OR REPLACE TRIGGER credex_del AFTER DELETE ON "credex" FOR EACH ROW EXECUTE FUNCTION credex_del();
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class Migration(BaseMigration):
|
|
39
|
+
dependencies: ClassVar = [("models", "0004_all_seed")]
|
|
40
|
+
operations: ClassVar = [RunSQL(CREDEX_DEL_SQL)]
|
|
@@ -1588,6 +1588,14 @@ class CredEx(Model):
|
|
|
1588
1588
|
credex, _ = await cls.update_or_create({"exid": exid}, cred_id=cred_id, ex_id=ex_id)
|
|
1589
1589
|
return credex
|
|
1590
1590
|
|
|
1591
|
+
@classmethod
|
|
1592
|
+
async def remove(cls, *, cred_id: int, ex_id: int) -> bool:
|
|
1593
|
+
"""ЕДИНСТВЕННЫЙ standalone-делитор CredEx (single-writer-правило): сносит строку (cred, ex).
|
|
1594
|
+
Снятие креда с ОДНОЙ биржи из формы — удаление на бирже реактивно: BEFORE/AFTER-DELETE триггер
|
|
1595
|
+
`credex_del` (миграция 0005) положит `[person_id, ex_id, exid]` в `credexs_del` → handler вызовет
|
|
1596
|
+
`acl.cred_del(exid)`. Каскадное удаление при сносе самого Cred идёт другим путём (`creds_del`)."""
|
|
1597
|
+
return bool(await cls.filter(cred_id=cred_id, ex_id=ex_id).delete())
|
|
1598
|
+
|
|
1591
1599
|
class Meta:
|
|
1592
1600
|
table_description = "Credential on Exchange"
|
|
1593
1601
|
unique_together = (("ex", "exid"),)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|