---
detect_relations: true

ContentType:
  tableName: content_types
  columns:
    id:
      type: string(32)
      primary: true
    title:
      type: string(64)
      notnull: true
    description: string
    managing_class:
      type: string(128)
      notnull: true

Node:
  tableName: nodes
  columns:
    id: &ID
      type: integer
      primary: true
      autoincrement: true
      unsigned: true
    title: string(64)
    state:
      type: integer
      unsigned: true
      notnull: true
      default: 1
    publish_timestamp:
      type: timestamp
      format: Y-m-d H:i:s
    revoke_timestamp:
      type: timestamp
      format: Y-m-d H:i:s
    content_type: string(32)
    content_id:
      type: integer
      unsigned: true
    tree_id: &IDREF
      type: integer
      unsigned: true
      notnull: true
    lft: *IDREF
    rgt: *IDREF
    level: *IDREF
  indexes:
    index_lft:
      fields: [lft]
    index_rgt:
      fields: [rgt]
    index_level:
      fields: [level]
    index_lft_rgt_tree_id:
      fields: [lft, rgt, tree_id]
    index_lft_rgt_level_tree_id:
      fields: [lft, rgt, level, tree_id]
  actAs:
    Timestampable: true
  relations:
    Tree:
      foreignAlias: Nodes
      onUpdate: cascade
      onDelete: cascade
    ContentType:
      local: content_type
      foreignAlias: Nodes
      onUpdate: cascade
      onDelete: cascade

Tree:
  tableName: trees
  columns:
    id: *ID
    title: string(32)
    type_id:
      type: string(32)
      notnull: true
  actAs:
    Timestampable: true
  relations:
    TreeType:
      local: type_id
      alias: Type
      foreignAlias: Trees
      onUpdate: cascade
      onDelete: restrict

TreeType:
  tableName: tree_types
  columns:
    id:
      type: string(32)
      primary: true
    name: string(32)
    description: string
    managing_class: string(128)
