Simple Data Import Question

I wanted to confirm an assumption I have about the data import tool for a project I will be working on.

Based on my reading and testing it doesn’t appear that the import tool can import one attribute of an existing table based on ID. All attributes from that entity need to be imported, correct?

Use Case - A production app was designed with int as data type, but now that field needs to be changed to accept decimal. Because changing the data type we lose the existing data from that attribute, to import that data back, I would need to import all the data (2000+ records that currently exist from that column, and about 15 other attributes, no compositions)

Thank you

hi,

No this is not correct. In order to update a particular entity record you can use a unique configuration: GitHub - mariodavid/cuba-component-data-import: CUBA component for easy data import

When you combine that with only one attribute binding for this particular attribute, this should do what you described.

Two comments here:

  1. are you really sure data loss is going to happen? E.g. in Postgres switching from INT to DECIMAL via ALTER COLUMN does not data loss.
  2. Normally it is a good idea to make a DB change backwards-compatible and also make the change independent from the java code change. On way in this scenario would be:
    2.1 Create new column with target type; keep the old column; keep the java code the same
    2.2 create trigger in DB to copy data from source column to target column and store it in the correct type next to the original column
    2.3 switch java code pointing to the new column
    2.4 remove the old column

Personally I would not try to solve this problem with the data-import plugin and instead with native SQL. That being said: it should just work fine.

Cheers
Mario

1 Like

Thank you so much Mario!
I appreciate the feedback and suggestion on how to move forward with the change. Exactly what I needed.

Regards
Stephen