Wijziging   A
last analyzed

Complexity

Total Complexity 0

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 8
Bugs 0 Features 0
Metric Value
wmc 0
c 8
b 0
f 0
dl 0
loc 43
rs 10
1
from sqlalchemy import (
2
    Column,
3
    Integer,
4
    String,
5
    DateTime
6
)
7
from sqlalchemy.ext.mutable import MutableDict
8
from sqlalchemy.dialects.postgresql import JSON
9
from sqlalchemy.sql import func
10
11
from oe_utils.data.models.meta import Base
12
13
14
class Wijziging(Base):
15
    """
16
    A database table configuration object containing information about the audit of a resource object.
17
18
    This object will not create the db table object.
19
    To create the table insert following code in the alembic migration file
20
21
    `alembic revision -m "wijzigingshistoriek"`
22
23
24
    from alembic import op
25
    import sqlalchemy as sa
26
    from sqlalchemy.dialects.postgresql import JSON
27
    from sqlalchemy.sql import func
28
29
30
    def upgrade():
31
        op.create_table('wijzigingshistoriek',
32
                        sa.Column('versie', sa.String(), nullable=False),
33
                        sa.Column('resource_object_id', sa.Integer(), nullable=False),
34
                        sa.Column('updated_at', sa.DateTime(timezone=True), default=func.now(), nullable=False),
35
                        sa.Column('updated_by', sa.String(length=255), nullable=False),
36
                        sa.Column('updated_by_omschrijving', sa.String(length=255), nullable=False),
37
                        sa.Column('resource_object_json', JSON, nullable=True),
38
                        sa.Column('actie', sa.String(length=50), nullable=False),
39
                        sa.PrimaryKeyConstraint('versie', name='wijzigingshistoriek_pk')
40
        )
41
42
        op.execute('GRANT ALL ON wijzigingshistoriek to <user>_dml')
43
44
45
    def downgrade():
46
        op.drop_table('wijzigingshistoriek')
47
    """
48
49
    __tablename__ = 'wijzigingshistoriek'
50
    versie = Column(String(64), primary_key=True)
51
    resource_object_id = Column(Integer, nullable=False)
52
    updated_at = Column(DateTime(timezone=True), default=func.now(), nullable=False)
53
    updated_by = Column(String(255), default='https://id.erfgoed.net/actoren/501', nullable=False)
54
    updated_by_omschrijving = Column(String(255), default='Onroerend Erfgoed', nullable=False)
55
    resource_object_json = Column(MutableDict.as_mutable(JSON()), nullable=True)
56
    actie = Column(String(50), nullable=False)
57
58