From fd87f19c31decd69cd10737762f9b94e8e5d6182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isak=20Ohlsson=20=C3=85ngnell?= <40887124+islean@users.noreply.github.com> Date: Tue, 24 Oct 2023 17:12:13 +0200 Subject: [PATCH] Add customer lab contact (#2595) (minor) ### Added - Column "lab_contact_id" to the Customer table. --- .../db61c62d9bc0_add_customer_lab_contact.py | 34 +++++++++++++++++++ cg/server/admin.py | 2 ++ cg/store/models.py | 2 ++ 3 files changed, 38 insertions(+) create mode 100644 alembic/versions/db61c62d9bc0_add_customer_lab_contact.py diff --git a/alembic/versions/db61c62d9bc0_add_customer_lab_contact.py b/alembic/versions/db61c62d9bc0_add_customer_lab_contact.py new file mode 100644 index 0000000000..0cdef035d2 --- /dev/null +++ b/alembic/versions/db61c62d9bc0_add_customer_lab_contact.py @@ -0,0 +1,34 @@ +"""Add customer lab contact + +Revision ID: db61c62d9bc0 +Revises: e853d21feaa0 +Create Date: 2023-10-05 12:53:28.435684 + +""" +import sqlalchemy as sa + +from alembic import op + +# revision identifiers, used by Alembic. +revision = "db61c62d9bc0" +down_revision = "e853d21feaa0" +branch_labels = None +depends_on = None + + +def upgrade(): + op.add_column( + table_name="customer", + column=sa.Column( + "lab_contact_id", + sa.INTEGER, + sa.ForeignKey(name="customer_lab_contact_fk_1", column="user.id"), + ), + ) + + +def downgrade(): + op.drop_constraint( + constraint_name="customer_lab_contact_fk_1", table_name="customer", type_="foreignkey" + ) + op.drop_column(table_name="customer", column_name="lab_contact_id") diff --git a/cg/server/admin.py b/cg/server/admin.py index e77fd936fa..1aaa046861 100644 --- a/cg/server/admin.py +++ b/cg/server/admin.py @@ -184,6 +184,7 @@ class CustomerView(BaseView): "collaborations", "comment", "delivery_contact", + "lab_contact", "loqus_upload", "primary_contact", "priority", @@ -194,6 +195,7 @@ class CustomerView(BaseView): "comment", "delivery_contact", "internal_id", + "lab_contact", "name", "primary_contact", "priority", diff --git a/cg/store/models.py b/cg/store/models.py index b2e7452296..25a297de51 100644 --- a/cg/store/models.py +++ b/cg/store/models.py @@ -300,6 +300,8 @@ class Customer(Model): invoice_address = Column(types.Text, nullable=False) invoice_reference = Column(types.String(32), nullable=False) is_trusted = Column(types.Boolean, nullable=False, default=False) + lab_contact_id = Column(ForeignKey("user.id")) + lab_contact = orm.relationship("User", foreign_keys=[lab_contact_id]) loqus_upload = Column(types.Boolean, nullable=False, default=False) name = Column(types.String(128), nullable=False) organisation_number = Column(types.String(32))