Autonumbering ID field

Autonumbering ID field

  

I have a child table, where I can save a picture, with reference to a parent table.I set the ID field of the child to autonumber and then want to update the parent table with this as image_Id, to connect the foreign key relationship. I am seeing this:

Database Upgrade Error
Column 'OSUSR_61J_<tablenam>PICTURE.ID' exists in database as Long Integer (bigint) but the new version is defined as Long Integer (Autonumber). Database bigint columns can not be changed to Autonumber.

This table is empty. Int is sufficient for row counts. If I can't change to autonumber, can I preset it, when the table is created?

Thanks

Hi,

Outsystems does not delete data from the application's entities, meaning that when a new version of an eSpace that no longer has a particular entity attribute is published, the correspondent column in the database will not be deleted thus avoiding deleting data from the database. Remember you can always rollback to a previous eSpace version.

You mention that your table is empty so, if your platform is on premisses, you can "DROP TABLE OSUSR_61J_<tablenam>;" using your SQL Management tool. When you republish, the platform will recreate the table.

If you are working on your personal environment, you should check DBCleaner.

Hope this helps

Lee, you can delete the entity in Service Studio, and create another entity with exactly the same name and same attributes. This new entity, being a new object in Service Studio, will create a brand new table when you publish, and thus won't have any upgrade problems.

The previous table will not be dropped, because, like Bruno Fonte said, you could roll back to a previous version of the application, and you'd expect the table from that previous version to be restored.

After you understand that a new table is created, even though you are publishing an entity with exactly the same name, you can start using a shortcut for this operation. Just cut the entity and paste it again. This has the same effect of deleting the entity and creating a brand new one.

Solution

Lee, 

Besides what was already told, I would like to point you what probably is going on.

When you create an entity, an Id field is automatically given to it. It is a long integer autonumber set to be the entity identifier.

You can change this, but only before you publish your espace.  

Once your entity was created in the database as a table, you are not allowed to change the ID field type or property's. If you need to change the identifier of a table after you publish, you can copy the entity and erase the old one, keeping the same name, change the id as you want and than publish (if the old table has data you will 'lost' it).

You can also try to delete the id and create a new one, but only if you give it a new name.

If the relationship between the two entities is a 1 to 1 (only a single picture allowed), I would prefer to recreate the entity and before publishing, change the identifier of the picture entity to be of type otherentity identifier, creating an extension entity.

This will enforce the 1 to 1 relationship, guaranteeing that only a single picture will exist connected with the other entity

Solution

Thanks for the pointers, guys. I appreciate the suggestions. They've helped my understanding of how data is handled. Tbh, I hadn't realized I could step back to prior e-spaces.

I still occasionally see duplicate data, when I delete tables and import them again. I think this is due to multiple import bootstrappers, if I forget to delete them with the entities. Does this make sense?

When you import an entity from an excel file, the IDE automatically creates a bootstrap timer for that. Timers are actions that run in background and without user interaction. You can check which timers you have on the Processes tree (use CTRL-1).

These timers are responsible for reading the excel file and populating your database table.

When you delete one entity and import it again from another excel file, it might happen that the old bootstrap timer is not deleted, and since you are creating a new one, you end up with two timers for the same entity.

You should really take a look at the timers on your module. You will find that there's nothing magical in the bootstrap from excel, and you can actually take control and customize it.

Leonardo Fernandes wrote:

When you import an entity from an excel file, the IDE automatically creates a bootstrap timer for that. Timers are actions that run in background and without user interaction. You can check which timers you have on the Processes tree (use CTRL-1).

These timers are responsible for reading the excel file and populating your database table.

When you delete one entity and import it again from another excel file, it might happen that the old bootstrap timer is not deleted, and since you are creating a new one, you end up with two timers for the same entity.

You should really take a look at the timers on your module. You will find that there's nothing magical in the bootstrap from excel, and you can actually take control and customize it.

Thanks Leonardo.

I found the bootstrap processes and I thought I had to delete them manually. I have never noticed them disappearing when I delete an entity. 

I am still very much a beginner, although I have done the online training and I am now on my own projects. It feels like my progress is slow...could use some more advanced training!


Thanks again.


Lee