How to add an sql script in the deployment

How to add an sql script in the deployment

Hi people,

I've a table without a unique key. I want to create a unique key on it, but in order to create the unique key, I have to remove duplicates. How can I attach a script to the deployment so it removes duplicates before adding the unique key? 

Hi Hans,

The only way I know how to do this is prior to the deployment and directly on the database. You can do this as well inside Service Studio but you would need to publish twice, one for remove the duplicates and another to introduce the changes in the entity (adding the unique key).

Hi Hans,

You can try to do it like Outsystems does it, use a bootstrap timer! Can you fit that script into an advanced query? If you can then this might be the solution.

Keep in mind that the script will be executed AFTER the rest of the SQL that Outsystems will create for the deploy process.