Search code examples
google-cloud-sqlgoogle-app-maker

Change data type on AppMaker


I use AppMaker with Google Cloud SQL and needed to change a String field to Date (StartDate).

A page on the AppMaker guides said 'To change the field type, delete and recreate the field.', as I deleted the field I was prompted to choose between 'Delete data' or 'Keep data', I chose keep data as I had input some already.

I then went on to recreate the field with the same name (StartDate) but as Date now and I get "Duplicate column name 'StartDate'".


Solution

  • This is an expected behavior. If you have a field with string data type and then you want to convert that to a date data type, app maker won't do that for you. These are two different types of data. Since you've chosen to keep the data, the field was deleted from app maker's interface; however, the data is still available in google cloud sql. If you really want to keep the data, you'll have to create a new field with a different name, but if you really need the field with the same name and a different data type, you'll need to do the following:

    1. In app maker, go to the app settings: enter image description here

    2.Then go the database and click on check: enter image description here

    1. You will be presented with the three options: enter image description here

    In summary, appmaker is not able to create the field with the same name and different data type because the field name already exists in the sql backend. The only thing you can do is to completely delete that field and get rid of the data, or restore the field and continue using strings. I hope this helps!