In my last article, I mentioned that we got stuck with a corrupted index in a managed solution. The reason the index became corrupted was that the width of the index we defined was exceeding the maximum with of an index within SQL Server. The hard lesson we learned that we should create small keys in which the size of all fields do not exceed 900 bytes (link).
On the development server we could repair the situation by dropping the keys we defined. On the target environments on which we deployed the solution the faulty key could not be deleted. In fact we were not able to update the managed solution. We got stuck.
We requested Microsoft to alter the created indexes, making the keys smaller. After a couple of requests (one request per environment) the indexes were made smaller (in case of an on premise environment we would have done the index repair ourselves). The environments were ready to be fixed…
From there on, we did the following steps per environment to get rid of the indexes in the managed solutions.
- Alter the solution on the development environment, by removing the keys we defined.
- Make a managed export of the altered solution.
- Copy the exported managed solution and rename it.
- Open the renamed solution file, and alter the unique name of the solution in the solution.xml.
- Import the altered and renamed solution in the target environment.
- Drop the orginal solution from the target environment.
- Import the managed solution (created in step 2).
- Drop the altered and renamed soluton in the target environment.
This looks like a large number of steps. In fact it is. But it is the only way we could drop the corrupted index on the target environment, preserving all data!
The trick is by installing the renamed solution (step 5) we preserved the data (same published). By uninstalling the original solution, we dropped all modifications made by that solution (including the corrupted index). Because the renamed solution contains the same entities, the data is kept in the new entities 🙂
Repeating the action by installing the altered solition (step 2) over the solution made in step 5, the data will be preserved in the entities defined in the altered solution. By removing the renamed solution, the system reverts back in the state where it should be.