ignores:
  - migrations
  - river_client
  - river_client_queue
  - river_job
  - river_leader
  - river_migration
  - river_queue
imports:
  - go.ipao.vip/gen
  - quyun/v2/pkg/consts
field_type:
  users:
    roles: types.Array[consts.Role]
    status: consts.UserStatus
  tenants:
    uuid: types.UUID
    status: consts.TenantStatus
  tenant_users:
    role: types.Array[consts.TenantUserRole]
    status: consts.UserStatus
  media_assets:
    type: consts.MediaAssetType
    status: consts.MediaAssetStatus
  contents:
    status: consts.ContentStatus
    visibility: consts.ContentVisibility
  content_assets:
    role: consts.ContentAssetRole
  content_prices:
    currency: consts.Currency
    discount_type: consts.DiscountType
  content_access:
    status: consts.ContentAccessStatus
  orders:
    type: consts.OrderType
    status: consts.OrderStatus
    currency: consts.Currency
  tenant_ledgers:
    type: consts.TenantLedgerType
  tenant_invites:
    status: consts.TenantInviteStatus
  tenant_join_requests:
    status: consts.TenantJoinRequestStatus
field_relate:
  users:
    OwnedTenant:
      relation: belongs_to
      table: tenants
      json: owned
    Tenants:
      json: tenants
      relation: many_to_many
      table: tenants
      pivot: tenant_users
      # foreign_key: user_id # 当前表（users）用于关联的键（转为结构体字段名 user_id）
      join_foreign_key: user_id # 中间表中指向当前表的列（tenant_users.user_id）
      # references: id # 关联表（tenants）被引用的列（转为结构体字段名 ID）
      join_references: tenant_id # 中间表中指向关联表的列（tenant_users.tenant_id）
  tenants:
    Users:
      relation: many_to_many
      table: users
      pivot: tenant_users
      json: users
      join_foreign_key: tenant_id
      join_references: user_id
  orders:
    Items:
      relation: has_many
      table: order_items
      json: items
      foreign_key: order_id
      references: id
  order_items:
    Order:
      relation: belongs_to
      table: orders
      json: order
      foreign_key: order_id
      references: id
    Content:
      relation: belongs_to
      table: contents
      json: content
      foreign_key: content_id
      references: id
  tenant_ledgers:
    Order:
      relation: belongs_to
      table: orders
      json: order
      foreign_key: order_id
      references: id
