forked from sr2/cloud-api
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
|
|
"""
|
||
|
|
Database models for organisation module
|
||
|
|
|
||
|
|
Models:
|
||
|
|
- Organisation: id[pk], name, status, intake_questionnaire,
|
||
|
|
billing_contact_id[fk], security_contact_id[fk], owner_contact_id[fk]
|
||
|
|
- OrgUsers: org_id[fk][cpk], user_id[fk][cpk], is_admin
|
||
|
|
"""
|
||
|
|
from sqlalchemy import Column, Integer, String, Boolean, ForeignKey, JSON, false
|
||
|
|
|
||
|
|
from src.database import Base
|
||
|
|
from src.contact.models import Contact
|
||
|
|
from src.user.models import User
|
||
|
|
|
||
|
|
|
||
|
|
class Organisation(Base):
|
||
|
|
__tablename__ = "organisation"
|
||
|
|
|
||
|
|
id = Column(Integer, primary_key=True)
|
||
|
|
name = Column(String)
|
||
|
|
status = Column(String, default="partial")
|
||
|
|
intake_questionnaire = Column(JSON)
|
||
|
|
|
||
|
|
billing_contact_id = Column(Integer, ForeignKey("contact.id"))
|
||
|
|
security_contact_id = Column(Integer, ForeignKey("contact.id"))
|
||
|
|
owner_contact_id = Column(Integer, ForeignKey("contact.id"))
|
||
|
|
|
||
|
|
|
||
|
|
class OrgUsers(Base):
|
||
|
|
__tablename__ = "orgusers"
|
||
|
|
|
||
|
|
org_id = Column(Integer, ForeignKey("organisation.id", ondelete="CASCADE"), primary_key=True)
|
||
|
|
user_id = Column(Integer, ForeignKey("user.id", ondelete="CASCADE"), primary_key=True)
|
||
|
|
is_admin = Column(Boolean, nullable=False, server_default=false())
|