We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1778
    • 659 Posts
    Hello Jason,
    and thanks for answering. So, if I understand well, and if I want my components compatibles with versions 2.0.x (before 2.0.O-rc3) I have to use the "old way" to define my indexes by adding the attributes "index" and "indexgrp" to each field element I want in my index... Am I right ?

    Or can I do both (attributes in fields and separate index definitions)in my schema to be "compatible" with actual 2.0.0 and ready for 2.0.5 ?
    IOW can I have both

    <field key="name" dbtype="varchar" precision="80" phptype="string" null="false" default="" index="unique" indexgrp="nameoffice" />
    <field key="office" dbtype="varchar" precision="80" phptype="string" null="true" default="" index="unique" indexgrp="nameoffice" />

    <index alias="nameoffice" name="nameoffice" primary="false" unique="true">
    <column key="name" collation="A" null="false" />
    <column key="office" collation="A" null="false" />
    </index>

    Or will it mess things up ?
    Thanks
      • 22303 MODX Staff
      • 10,725 Posts
      Quote from: anso at Oct 27, 2010, 09:17 AM

      and thanks for answering. So, if I understand well, and if I want my components compatibles with versions 2.0.x (before 2.0.O-rc3) I have to use the "old way" to define my indexes by adding the attributes "index" and "indexgrp" to each field element I want in my index... Am I right ?
      Your are correct, except when I referred to 2.0.0-rc3 I was referring to the xPDO release, vs. 2.0.x where I was referring to MODx Revolution; sorry if that was confusing. IOW xPDO v2.0.0-rc3 is going to be in MODx 2.0.5-pl. So to be clear, any components with custom schema’s should continue to use the old index attributes when targeting MODx 2.0.x releases, even though MODx 2.0.5 will have support for the new indexes. But since previous MODx 2.0.x releases do not, uploading a component that relies on this new feature, and marked as supporting MODx 2.0, it will be available to any MODx 2.0.x release and would fail to create the indexes using the SCHEMA_VERSION 1.1 method in pre-2.0.5 releases.

      Note that in order for a component to use the new indexing method, the schema must include the version="1.1" attribute on the model element (and the maps must be regenerated to include this version data) or xPDO assumes it should look for the older index/indexgrp attributes to create the indexes from.

      Quote from: anso at Oct 27, 2010, 09:17 AM

      Or can I do both (attributes in fields and separate index definitions)in my schema to be "compatible" with actual 2.0.0 and ready for 2.0.5 ?
      IOW can I have both

      <field key="name" dbtype="varchar" precision="80" phptype="string" null="false" default="" index="unique" indexgrp="nameoffice" />
      <field key="office" dbtype="varchar" precision="80" phptype="string" null="true" default="" index="unique" indexgrp="nameoffice" />

      <index alias="nameoffice" name="nameoffice" primary="false" unique="true">
      <column key="name" collation="A" null="false" />
      <column key="office" collation="A" null="false" />
      </index>

      Or will it mess things up ?
      Having them both won’t mess anything up, but when releasing components that support MODx 2.0, make sure you do not use the SCHEMA_VERSION 1.1. IOW, do not mark the schema model with the attribute version="1.1" and regenerate the maps until you target MODx 2.1 with your component. That does mean the index elements will be ignored in your model however, regardless if it is MODx 2.0.5 or 2.0.4.

      Also, there is a utility script in xPDO 2.0.0-rc3 now (CLI or web executable) that will automatically convert your schema and model to SCHEMA_VERSION 1.1 (automatically converting your index/indexgrp attributes into the new index elements) when you are ready, so you can focus on other things for now and take advantage of the new SCHEMA_VERSION when you are ready to target MODx 2.1 with a component model. Or now if you have a project that just uses xPDO by itself.