Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

auth.accounts

Description

users account table

Columns

NameTypeDefaultNullableChildrenComment
connected_attimestamp with time zonenow()false
created_attimestamp with time zonenow()false
emailcitextfalseauth.otp auth.vessels
firsttextfalseUser first name with CONSTRAINT CHECK
idintegerfalse
lasttextfalseUser last name with CONSTRAINT CHECK
passtextfalse
preferencesjsonb‘{“email_notifications”: true}’::jsonbtrue
rolenamefalse
updated_attimestamp with time zonenow()false
user_idtext“right”((gen_random_uuid())::text, 12)false

Constraints

NameTypeDefinition
accounts_connected_at_not_nullnNOT NULL connected_at
accounts_created_at_not_nullnNOT NULL created_at
accounts_email_checkCHECKCHECK ((email ~* ‘^.+@.+..+$’::citext))
accounts_email_not_nullnNOT NULL email
accounts_first_not_nullnNOT NULL first
accounts_id_keyUNIQUEUNIQUE (id)
accounts_id_not_nullnNOT NULL id
accounts_last_not_nullnNOT NULL last
accounts_pass_not_nullnNOT NULL pass
accounts_pkeyPRIMARY KEYPRIMARY KEY (email)
accounts_role_not_nullnNOT NULL role
accounts_updated_at_not_nullnNOT NULL updated_at
accounts_user_id_keyUNIQUEUNIQUE (user_id)
accounts_user_id_not_nullnNOT NULL user_id
ensure_user_role_existsTRIGGERCREATE CONSTRAINT TRIGGER ensure_user_role_exists AFTER INSERT OR UPDATE ON auth.accounts NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION auth.check_role_exists()
valid_emailCHECKCHECK ((length((email)::text) > 5))
valid_firstCHECKCHECK (((length(first) > 1) AND (length(first) < 512)))
valid_lastCHECKCHECK (((length(last) > 1) AND (length(last) < 512)))
valid_passCHECKCHECK (((length(pass) > 4) AND (length(pass) < 512)))

Indexes

NameDefinition
accounts_id_keyCREATE UNIQUE INDEX accounts_id_key ON auth.accounts USING btree (id)
accounts_pkeyCREATE UNIQUE INDEX accounts_pkey ON auth.accounts USING btree (email)
accounts_preferences_idxCREATE INDEX accounts_preferences_idx ON auth.accounts USING gin (preferences)
accounts_user_id_keyCREATE UNIQUE INDEX accounts_user_id_key ON auth.accounts USING btree (user_id)

Triggers

NameDefinitionComment
accounts_moddatetimeCREATE TRIGGER accounts_moddatetime BEFORE UPDATE ON auth.accounts FOR EACH ROW EXECUTE FUNCTION moddatetime(‘updated_at’)Automatic update of updated_at on table modification
encrypt_passCREATE TRIGGER encrypt_pass BEFORE INSERT OR UPDATE ON auth.accounts FOR EACH ROW EXECUTE FUNCTION auth.encrypt_pass()execute function auth.encrypt_pass()
ensure_user_role_existsCREATE CONSTRAINT TRIGGER ensure_user_role_exists AFTER INSERT OR UPDATE ON auth.accounts NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION auth.check_role_exists()ensure user role exists
new_account_entryCREATE TRIGGER new_account_entry AFTER INSERT ON auth.accounts FOR EACH ROW EXECUTE FUNCTION new_account_entry_fn()Add new account in process_queue for further processing

Relations

erDiagram

"auth.otp" |o--|| "auth.accounts" : "FOREIGN KEY (user_email) REFERENCES auth.accounts(email) ON DELETE RESTRICT"
"auth.vessels" }o--|| "auth.accounts" : "FOREIGN KEY (owner_email) REFERENCES auth.accounts(email) ON DELETE RESTRICT"
"api.metadata" |o--|| "auth.vessels" : "FOREIGN KEY (vessel_id) REFERENCES auth.vessels(vessel_id) ON DELETE RESTRICT"

"auth.accounts" {
  timestamp_with_time_zone connected_at ""
  timestamp_with_time_zone created_at ""
  citext email ""
  text first "User first name with CONSTRAINT CHECK"
  integer id ""
  text last "User last name with CONSTRAINT CHECK"
  text pass ""
  jsonb preferences ""
  name role ""
  timestamp_with_time_zone updated_at ""
  text user_id ""
}
"auth.otp" {
  text otp_pass ""
  timestamp_with_time_zone otp_timestamp ""
  smallint otp_tries ""
  citext user_email FK ""
}
"auth.vessels" {
  timestamp_with_time_zone created_at ""
  numeric mmsi "MMSI can be optional but if present must be a valid one and unique but must be in numeric range between 100000000 and 800000000"
  text name ""
  citext owner_email FK ""
  name role ""
  timestamp_with_time_zone updated_at ""
  text vessel_id ""
}
"api.metadata" {
  boolean active "trigger monitor online/offline"
  jsonb available_keys "Signalk paths with unit for custom mapping"
  double_precision beam ""
  jsonb configuration "User-defined Signalk path mapping for metrics"
  timestamp_with_time_zone created_at ""
  double_precision height ""
  text ip "Store vessel ip address"
  double_precision length ""
  text mmsi "Maritime Mobile Service Identity (MMSI) number associated with the vessel, link to public.mid"
  text name ""
  text platform ""
  text plugin_version ""
  numeric ship_type "Type of ship associated with the vessel, link to public.aistypes"
  text signalk_version ""
  timestamp_with_time_zone time ""
  timestamp_with_time_zone updated_at ""
  jsonb user_data "User-defined data including vessel polar (theoretical performance), make/model, and preferences"
  text vessel_id FK "Link auth.vessels with api.metadata via FOREIGN KEY and REFERENCES"
}

Generated by tbls