xo::db::Attribute method create_attribute (public)

 <instance of xo::db::Attribute[i]> create_attribute

Defined in

Create an OpenACS attribute, if not already defined (or attribute creation is turned off for this xo::db::Attribute)

Testcases:
No testcase defined.
Source code:
if {!${:create_acs_attribute}} return

set object_type [${:domain} object_type]
#ns_log notice "::xo::db::Attribute create_attribute $object_type ${:column_name} epoch [ns_ictl epoch] [array get ::db_state_default]"

if {![:db_attribute_defined -object_type $object_type -attribute_name ${:column_name} ]} {

  #ns_log notice "GN: Attribute create_attribute flushes acs_attributes cache"
  nsv_unset -nocomplain acs_attributes acs_attributes

  if {![::xo::db::Class object_type_exists_in_db -object_type $object_type]} {
    ${:domain} create_object_type
  }

  ::acs::dc call acs_attribute create_attribute  -object_type    $object_type  -attribute_name ${:column_name}  -datatype       ${:datatype}  -pretty_name    ${:pretty_name}  -min_n_values   ${:min_n_values}  -max_n_values   ${:max_n_values}

  if {[::acs::icanuse "nsv_dict"]} {
    nsv_dict set acs_attributes $object_type ${:column_name} 1
  }
}
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: