---
detect_relations: true

Session:
  tableName: user_sessions
  columns:
    token:
      type: string(128)
      primary: true
    created:
      type: timestamp
      notnull: true
    last_activity:
      type: timestamp
    user_id:
      type: integer
      unsigned: true
      notnull: true
    consumer_name:
      type: string(64)
      notnull: true
    impersonated_user_id:
      type: integer
      unsigned: true
    auth_method_name:
      type: string(32)
      notnull: true
    state:
      type: string(16)
      notnull: true
  relations:
    User:
      foreignAlias: Sessions
      local: user_id
      foreign: id
      onUpdate: cascade
      onDelete: cascade
    ImpersonatedUser:
      foreignAlias: Sessions
      class: User
      local: user_id
      foreign: id
      onUpdate: cascade
      onDelete: cascade
    AuthMethod:
      foreignAlias: Sessions
      local: auth_method_name
      foreign: id
      onUpdate: cascade
      onDelete: cascade

SessionValue:
  tableName: user_session_values
  columns:
    token:
      type: string(128)
      primary: true
    name:
      type: string(128)
      primary: true
    value:
      type: text
  relations:
    Session:
      foreignAlias: Values
      local: token
      foreign: token
      onUpdate: cascade
      onDelete: cascade

SessionImpersonatedValue:
  tableName: user_session_impersonatedvalues
  columns:
    token:
      type: string(128)
      primary: true
    name:
      type: string(128)
      primary: true
    value:
      type: text
  relations:
    Session:
      foreignAlias: ImpersonatedValues
      local: token
      foreign: token
      onUpdate: cascade
      onDelete: cascade
