-- SPDX-FileCopyrightText: 2022 Sarah Vaupel <sarah.vaupel@ifi.lmu.de>,Steffen Jost <jost@tcs.ifi.lmu.de>
--
-- SPDX-License-Identifier: AGPL-3.0-or-later

-- Description of companies associated with users

Company  
  name            CompanyName             -- == (CI Text)
  shorthand       CompanyShorthand        -- == (CI Text) and CompanyKey :: CompanyShorthand -> CompanyId    FUTURE TODO: a shorthand will become available through the AVS interface in the future
  avsId           Int     default=0       -- primary key from avs
  prefersPostal   Bool    default=false   -- new company users prefers letters by post instead of email
  postAddress     StoredMarkup Maybe      -- default company postal address  
  UniqueCompanyName name 
  UniqueCompanyShorthand shorthand
  -- UniqueCompanyAvsId avsId             -- should be the case, unclear if enforcing works here, since we cannot query avs by company id
  Primary shorthand             -- newtype Key Company = CompanyKey { unSchoolKey :: CompanyShorthand }
  deriving Ord Eq Show Generic

-- TODO: a way to populate this table (manually)
CompanySynonym
  synonym     CompanyName
  canonical   CompanyShorthand OnDeleteCascade OnUpdateCascade
  UniqueCompanySynonym synonym
  deriving Ord Eq Show Generic
