Wrongly setting datatype

I have faced this problem a several times already and it bugs me lots.

Let's say I wrongly set an attribute data type to Date, is there a way for me to change it to let's say Integer / Identifier?

I do not mind to wipe out my existing DB at all since it's still in the development stage.

The only way I could think of is to delete the attribute and start a new one with a slightly different name to work around. But that sounds really bad

Hi Stephen,

I think this is on purpose, to allow the system to restore database to a previous state when you publish an old version of the module.

It also does not delete the field in the database table, nor it deletes the data already there (or the constraints).

So, you can create a new attribute, or, if you still does not have this entity in production, you can cut and paste the entity, change the data type and publish the module.

A new entity will be created both in the database as well as in OutSystems, so you will have to fix any dependencies.

Cheers.

Eduardo Jauch wrote:

Hi Stephen,

I think this is on purpose, to allow the system to restore database to a previous state when you publish an old version of the module.

It also does not delete the field in the database table, nor it deletes the data already there (or the constraints).

So, you can create a new attribute, or, if you still does not have this entity in production, you can cut and paste the entity, change the data type and publish the module.

A new entity will be created both in the database as well as in OutSystems, so you will have to fix any dependencies.

Cheers.

The Attribute is already there with Data Type = Date, so nothing I can do about it? my situation is like CreatedByID Data Type = Date..... Feeling so helpless 


In the past (version 9 at least), I "think" if you cut and paste an attribute, it would create a new one in the database table, so you could keep using the same name. But I am not sure.

Could you test this? Cut your attribute, paste it and change the data type?

In any case, even if this works, it will still be a new field in the physical table.

Cheers.

P.S. A workaround would be to delete the field, publish the module, go to DBCleaner and delete the field from the database. Not sure if this is allowed if there is still a version in the system that uses this field. If you wipe your past versions this should work. Maybe...

Eduardo Jauch wrote:

In the past (version 9 at least), I "think" if you cut and paste an attribute, it would create a new one in the database table, so you could keep using the same name. But I am not sure.

Could you test this? Cut your attribute, paste it and change the data type?

In any case, even if this works, it will still be a new field in the physical table.

Cheers.

P.S. A workaround would be to delete the field, publish the module, go to DBCleaner and delete the field from the database. Not sure if this is allowed if there is still a version in the system that uses this field. If you wipe your past versions this should work. Maybe...

I tried to install DBCleaner but it says the version is incompatible. Im using Outsystems 11


I tried to cut and paste, then amend the Data Type to User Identifier, it pops up the same error as without cut and paste: 

Invalid Data Type
'User Identifier' data type required instead of 'Date'.

Stephen Li wrote:

Eduardo Jauch wrote:

In the past (version 9 at least), I "think" if you cut and paste an attribute, it would create a new one in the database table, so you could keep using the same name. But I am not sure.

Could you test this? Cut your attribute, paste it and change the data type?

In any case, even if this works, it will still be a new field in the physical table.

Cheers.

P.S. A workaround would be to delete the field, publish the module, go to DBCleaner and delete the field from the database. Not sure if this is allowed if there is still a version in the system that uses this field. If you wipe your past versions this should work. Maybe...

I tried to install DBCleaner but it says the version is incompatible. Im using Outsystems 11


I tried to cut and paste, then amend the Data Type to User Identifier, it pops up the same error as without cut and paste: 

Invalid Data Type
'User Identifier' data type required instead of 'Date'.

There is a version of DBCleaner for platform 11. How are you installing it? If you install from inside Service Studio it should choose automatically the correct version.

Also, the field is a FK? Or the Primary Key (Entity Identifier) of the entity? I think those you never can change the data type...


Eduardo Jauch wrote:

Stephen Li wrote:

Eduardo Jauch wrote:

In the past (version 9 at least), I "think" if you cut and paste an attribute, it would create a new one in the database table, so you could keep using the same name. But I am not sure.

Could you test this? Cut your attribute, paste it and change the data type?

In any case, even if this works, it will still be a new field in the physical table.

Cheers.

P.S. A workaround would be to delete the field, publish the module, go to DBCleaner and delete the field from the database. Not sure if this is allowed if there is still a version in the system that uses this field. If you wipe your past versions this should work. Maybe...

I tried to install DBCleaner but it says the version is incompatible. Im using Outsystems 11


I tried to cut and paste, then amend the Data Type to User Identifier, it pops up the same error as without cut and paste: 

Invalid Data Type
'User Identifier' data type required instead of 'Date'.

There is a version of DBCleaner for platform 11. How are you installing it? If you install from inside Service Studio it should choose automatically the correct version.

Also, the field is a FK? Or the Primary Key (Entity Identifier) of the entity? I think those you never can change the data type...


Installing from Forge in Studio. It shows the following:


Application cannot be safely installed in your environmentOutSystems Platform dependency analysis has detected that installing this application would impact other applications running in your environment. You may still force the installation of the application at your own risk.DBCleaner is not compatible with your platform version.


Should I click on Force Install?


Also Im trying to add a button at my main website (So not the Core) and write my own SQL trying to drop the column, but it says insufficient privileges.

Yes, you can't do DDL inside OutSystems, as the user used to access the database does not have privileges. In general it is safe to force installation... Is it a personal environment? It was upgraded from a previous version? (O10).

Eduardo Jauch wrote:

Yes, you can't do DDL inside OutSystems, as the user used to access the database does not have privileges. In general it is safe to force installation... Is it a personal environment? It was upgraded from a previous version? (O10).

It is not a personal environment i think. I can always just reverse by uninstalling right?

if you don't care about the data, why not simply cut+paste the table, change the attribute and publish?


How do you not know if it is a personal environment? :D

In any case, DBCleaner has no dependencies and no one uses it, unless you already have it in your environment and has an application that uses it in someway... In that case, you may lost what was made... And I think in this case removing it from the environment  will not restore the previous version...

J. wrote:

if you don't care about the data, why not simply cut+paste the table, change the attribute and publish?


Thanks for your input! After I did what you asked it still popped up the same error preventing me from publishing:

Invalid Data Type
'Integer' data type required instead of 'Date'.


J. wrote:

if you don't care about the data, why not simply cut+paste the table, change the attribute and publish?


I had problems doing that in version 11...


Eduardo Jauch wrote:

How do you not know if it is a personal environment? :D

In any case, DBCleaner has no dependencies and no one uses it, unless you already have it in your environment and has an application that uses it in someway... In that case, you may lost what was made... And I think in this case removing it from the environment  will not restore the previous version...

Haha sorry I am not sure what you mean by personal environment, it is a business project so i think it is not xD

And for that part I interpret as I do not have anything depending on DBCleaner so it wont affect anything if I install use it and uninstall it.

You can try to copy the entity, change the attribute, publish, than delete the old one and rename the new one.

Stephen Li wrote:

Haha sorry I am not sure what you mean by personal environment, it is a business project so i think it is not xD

And for that part I interpret as I do not have anything depending on DBCleaner so it wont affect anything if I install use it and uninstall it.

If so, yes :)


Eduardo Jauch wrote:

You can try to copy the entity, change the attribute, publish, than delete the old one and rename the new one.

Nice suggestion! But I have no idea why, everytime I delete an entity there is an error pointing to the Bootstrap actions...:

Invalid Variable
Unknown object 'Entity1Record.AgreementLocation.LastUpdatedByID' in variable.


Well...

If you have bootstrap using that entity you just deleted, it will give you an error.
In that case, you have to replace, in logic, all references to the old entity to the new one.

Eduardo Jauch wrote:

Well...

If you have bootstrap using that entity you just deleted, it will give you an error.
In that case, you have to replace, in logic, all references to the old entity to the new one.

I just did what you told me to, to copy publish then delete the old one and change the new one's name. From the logic Bootstrap action, it points to one of the assign value :


SyntaxEditor Code Snippet

ConvertFromExcel.Current.Excel_AgreementLocation.LastUpdatedByID

and says 'Integer' data type required instead of 'Date'.

This is because your structure, used to convert the excel to a list, still has the wrong data type for this field, and probably your excel file (that was uploaded to the server), also has the wrong data (you need to replace it by a correct one in the resources).

Eduardo Jauch wrote:

This is because your structure, used to convert the excel to a list, still has the wrong data type for this field, and probably your excel file (that was uploaded to the server), also has the wrong data (you need to replace it by a correct one in the resources).

Yes exactly... That's why I got this problem right now :( Is it possible to jump into the excel and change it now XD


You can download the excel (from the resources), fix it, and than replace the one in the resources with the new one...

Eduardo Jauch wrote:

You can download the excel (from the resources), fix it, and than replace the one in the resources with the new one...

I just digged into those and fix those errors, but once I publish.

Database Upgrade Error
Column 'XXXXX_XXX_AGREEME7.LASTUPDATEDBYID' exists in database as DateTime (TIMESTAMP(6)) but the new version is defined as Integer (NUMBER(10)). Database TIMESTAMP(6) columns can not be changed to NUMBER(10).

Did you still have the old entity or did you deleted it?
And the error happens on publishing?

Eduardo Jauch wrote:

Did you still have the old entity or did you deleted it?
And the error happens on publishing?

What I did was copy the ID entity, paste, amend the data type, publish, delete the old one, change the new's name to the old's name. publish. fix the excel, publish again and this error pops

I dont see any way to fix this problem... All I can do now is to create another attribute called LastUpdatedByID2 instead.... I think this is a huge drawback for Outsystems during development. 

DBCleaner is not usable at the moment for me, it only shows an error page to ask me to contact the admin for every page of DBCleaner I visited. 

I really hope Outsystems provides a more flexible and handy way to amend the DataType. I understand part of the rationale behind but still as a developer this is quite troublesome.