File: 20210413170734_6_7.py

package info (click to toggle)
python-beanie 2.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,480 kB
  • sloc: python: 14,427; makefile: 7; sh: 6
file content (48 lines) | stat: -rw-r--r-- 1,092 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from pydantic.main import BaseModel

from beanie import Document, iterative_migration


class Tag(BaseModel):
    color: str
    name: str


class Note(Document):
    title: str
    tag: Tag

    class Settings:
        name = "notes"


class Forward:
    @iterative_migration()
    async def change_title_6(
        self, input_document: Note, output_document: Note
    ):
        if input_document.title == "6":
            output_document.title = "six"

    @iterative_migration()
    async def change_title_7(
        self, input_document: Note, output_document: Note
    ):
        if input_document.title == "7":
            output_document.title = "seven"


class Backward:
    @iterative_migration()
    async def change_title_7(
        self, input_document: Note, output_document: Note
    ):
        if input_document.title == "seven":
            output_document.title = "7"

    @iterative_migration()
    async def change_title_6(
        self, input_document: Note, output_document: Note
    ):
        if input_document.title == "six":
            output_document.title = "6"