Seed data cleaning issue

Hi all,
I’m experiencing a very annoying issue related to seed data. I try to explain the scenario the best way I can.

  • I have a Type which mixes Config and it is used to inject pre-compiled configurations in a specific Type MyPackageAssetConfig.
    — It provides a start field in order to define the time from which the configuration is valid.
    — It mixes Config, SeedData

  • I have a Type Asset which has a stored calc field which contains a list of MyPackageAssetConfig instances ordered in descending order by the start field.

The first this I would like to do is provide seed data with a unique JSON file, by means of the following structure:

{
  "type": ["MyPackageAssetConfig"],
  "value": [
    {
      "id": "idX_11",
      "isPowerOffMetricName": "MetricName",
      "flameOnTagName": [
        "51APT027A"
      ],
      "flameOnReferenceValue": [
        10
      ],
      "start": "2019-06-12T17:00:00",
      "asset": {"id": "idX"}
    },
    {
      "id": "idY_11",
      "isPowerOffMetricName": "MetricName",
      "flameOnTagName": [
        "51APT027A"
      ],
      "flameOnReferenceValue": [
        10
      ],
      "start": "2019-06-12T17:00:00",
      "asset": {"id": "idY"}
    }
  ]
}

After this trial, the tag started providing errors during each provisioning (even with RESET flag). The error is related the duplicated ids for the reference keys generated.

Error message: Object with same values already exists in Type MyPackageAssetConfig for unique index C2_2_TGSTRASST_CFG_FLMN_K.

I tried with MyPackageAssetConfig.removeAll() and MyPackageAssetConfig.removeSeedData().

One thing which I do not understand. If I run MyPackageAssetConfig.fetch() I get empty result, but if I run:

  • c3Grid(DbAdmin.executeQuery("SELECT COUNT(DISTINCT id) FROM C3_2_TGSTRASST_CFG LIMIT 2002").results)
    — Result is 452

  • c3Grid(DbAdmin.executeQuery("SELECT COUNT(id) FROM C3_2_TGSTRASST_CFG LIMIT 2002").results)
    — Result is 504

Why isn’t it 0 ?

Thanks,
Riccardo

Do you get any results if you fetch with fetchHiddenSeedData: true ?

Hi Matt,
I get no values for the following code:

c3Grid(MyPackageAssetConfig.fetch({
    fetchHiddenSeedData: true
}))

Reading the post you mentioned, this should be correct since MyPackageAssetConfig mixes Config, SeedData and I removed data with removeSeedData().

Now, I have some other questions:

  • Do I have to make a Type A mix SeedData when I expect to provision a package with seed files which populate the Type A?
    — I suppose the answer is YES.
    — Moreover, it is not rare that such Type instances are modified during application execution. Such modifications make the Type not modifiable anymore during provisioning. An example, a CronJob which is provisioned with field "inactive":true and later set to false at runtime is never set to true again after a new provisioning with the same seed data.
  • When I want to remove the instances of a Type A (with removeSeedData), do I have to remove all instances of Type B which contain references to Type A? An example: Type MyPackageAsset contains a list of [MyPackageAssetConfig].
    — I think (hope) the answer is NO in this case.
  • Finally, Is there some kind of tricky point when I deal with fields of the following type?
    flameOnReferenceValue: [double] schema suffix 'FLMN_RFV'

This is the expected behavior of types that mix SeedData.

No, you do not need to mix SeedData in order to provision data for a type via myPackage/seed/**/*.json


You don’t have to remove instances of Type B, but those instances of Type B will still have an “invalid” reference to the instances of Type A. The references won’t be removed for you, even if they’re no longer valid. (Am I understanding your question correctly?)


Are you getting errors for both C2_2_TGSTRASST_CFG_FLMN_RFV_K and C2_2_TGSTRASST_CFG_FLMN_K? _FLMN_RFV_K sounds like it’s a table for your flameOnReferenceValue values.

@trothwein any ideas here?

What version is this on. Is there a url I can access to investigate what is going on?