cannot create unique index - upgrade error

Hi,

I'm doing Bookings Assignment.
Some errors occurred and I cannot solve them on my own. Please help me.

One of them is "cannot create unique index" - upgrade error.

Here error log says:

------------------------------------------------------------
Upgrade Error: Could not create unique index on 'ROOMID,AMENITYID' of entity 'RoomAmenity'. It has duplicate values.

Error logged at:
   at OutSystems.HubEdition.ServerCommon.Tasks.AbstractTask`1.InnerRun(InputType input, IMessageBroker messageBroker, Func`1 executeAction)
   at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
   at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()

------------------------------------------------------------

I have RoomAmentity Entity which relates to Room Entity and Amenity Entity.
I tried to make Unique Index to RoomAmenity Entity but I could not because of the error.
It says 'duplicate values' but I did not make any index.

If you give a hint or a solution, I would really appreciate that.

Thank you,
Mai

Solution

Hello Mai,

you must delete the duplicate record on RoomAmentity entity, without that it not be possible to create the unique index.

You can use the Advanced SQL action to delete the record, or better delete all and start over with clean and fresh data.

Regards

Carl

Solution

Hello Mai,

What fields you are tryng to create on the index? 


Mai Goryo wrote:

Hi,

I'm doing Bookings Assignment.
Some errors occurred and I cannot solve them on my own. Please help me.

One of them is "cannot create unique index" - upgrade error.

Here error log says:

------------------------------------------------------------
Upgrade Error: Could not create unique index on 'ROOMID,AMENITYID' of entity 'RoomAmenity'. It has duplicate values.

Error logged at:
   at OutSystems.HubEdition.ServerCommon.Tasks.AbstractTask`1.InnerRun(InputType input, IMessageBroker messageBroker, Func`1 executeAction)
   at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
   at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()

------------------------------------------------------------

I have RoomAmentity Entity which relates to Room Entity and Amenity Entity.
I tried to make Unique Index to RoomAmenity Entity but I could not because of the error.
It says 'duplicate values' but I did not make any index.

If you give a hint or a solution, I would really appreciate that.

Thank you,
Mai



you need to remove duplicate fields if you want to create unique index in any database.

I would suggest you to create a new attributes roomid and aminityid in roomAminity entitiy and create unique index on that and remove existing attributes (roomid and aminityid).

or as per carls suggestion just delete that entity and create new one and first create unique index and then insert record in that entity. .

Hi all,

Thank you for your all reply!
It was amazing that members in this forum reply so fast.

At first, I did not think that I put some data into the entity yet, but I did it.
Therefore, as Carl suggested, I deleted the entity and re-create it.
Then, actually it works. I could create the unique index.

I will never forget to create unique index before testing it.

Thank you, indeed,
Mai

Hi Mai,

Good to know that we can help you!


Happy coding