unable to publish - application didn´t change Primary Key structure

unable to publish - application didn´t change Primary Key structure

  
I decided to change the PK type of Funcionario (Employee) from text to int. I fixed all errors and tried to publish. For my suprise I could not more use the Funcionario pages. It seems that I have to drop the table and start all again. Someone have some turnaround to help me ? See errors below and tables attached.

Publishing Error

Unable to upgrade database schema. Error trying to change database field 'OSUSR_k1p_Funcionario.ID' type (New Def: INT Mandatory in DB; DB Def: NVARCHAR(20) Mandatory in DB).
Exception: The object 'OSPRK_OSUSR_K1P_FUNCIONARIO' is dependent on column 'ID'.
ALTER TABLE ALTER COLUMN ID failed because one or more objects access this column.
SQL: alter table "WSY9NZ014"."DBO"."OSUSR_K1P_FUNCIONARIO" alter column "ID" INT;


Exception Details:
[1] Publishing Error: Unable to upgrade database schema. Error trying to change database field 'OSUSR_k1p_Funcionario.ID' type (New Def: INT Mandatory in DB; DB Def: NVARCHAR(20) Mandatory in DB).
Exception: The object 'OSPRK_OSUSR_K1P_FUNCIONARIO' is dependent on column 'ID'.
ALTER TABLE ALTER COLUMN ID failed because one or more objects access this column.
SQL: alter table "WSY9NZ014"."DBO"."OSUSR_K1P_FUNCIONARIO" alter column "ID" INT;

at #8Yd.#u3.#Y2d(HEMessageArrayList warnings, IDbTransaction adminTrans, Dictionary`2 schemaTransactions, String fullQuery, Int32 updateDBTimeout)
   at #8Yd.#u3.#X2d(String eSpaceName, HEMessageArrayList warnings, String eSpaceKey, Int32 eSpaceVersionId, DeployPhase phase, String uniqueId)
   at #8Yd.#u3.#L2d(String eSpaceName, Int32 eSpaceVersionId, String uniqueId, String username, DeployPhase phase)
   at #8Yd.#u3.#L2d(ICompilerContext context, String eSpaceName, Int32 eSpaceVersionId, String uniqueId, String username, DeployPhase phase)
   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
   at System.Runtime.Remoting.Messaging.ServerObjectTerminatorSink.SyncProcessMessage(IMessage reqMsg)
   at System.Runtime.Remoting.Messaging.ServerContextTerminatorSink.SyncProcessMessage(IMessage reqMsg)
   at System.Runtime.Remoting.Channels.CrossContextChannel.SyncProcessMessageCallback(Object[] args)
   at System.Runtime.Remoting.Channels.ChannelServices.DispatchMessage(IServerChannelSinkStack sinkStack, IMessage msg, IMessage& replyMsg)
   at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)
   at #8Yd.#u3.#F4d.#C4d(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)
   at System.Runtime.Remoting.Channels.Tcp.TcpServerTransportSink.ServiceRequest(Object state)
   at System.Runtime.Remoting.Channels.SocketHandler.ProcessRequestNow()
   at System.Runtime.Remoting.Channels.SocketHandler.BeginReadMessageCallback(IAsyncResult ar)
   at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
   at System.Threading.ExecutionContext.runTryCode(Object userData)
   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Net.ContextAwareResult.Complete(IntPtr userToken)
   at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
   at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
[2] System.Data.SqlClient.SqlException: The object 'OSPRK_OSUSR_K1P_FUNCIONARIO' is dependent on column 'ID'.
ALTER TABLE ALTER COLUMN ID failed because one or more objects access this column.
   at OutSystems.HubEdition.RuntimePlatform.DBHelper.#qbb(DbException e, IDbTransaction trans)
   at OutSystems.HubEdition.RuntimePlatform.DBHelper.ExecuteNonQueryDontCleanParameters(IDbCommand cmd, String description, Boolean isApplication, Boolean skipLog)
   at OutSystems.HubEdition.RuntimePlatform.DBHelper.ExecuteNonQuery(IDbCommand cmd)
   at OutSystems.HubEdition.DeploymentController.DBCompilerService.ExecuteInlineStatementWithTimeout(IDbTransaction tran, String statement, Int32 timeout)
   at #8Yd.#u3.#Y2d(HEMessageArrayList warnings, IDbTransaction adminTrans, Dictionary`2 schemaTransactions, String fullQuery, Int32 updateDBTimeout)
You cannot change a TEXT to an INT. You would need to create a second attribute, copy the data into it, then remove the first and make the second the Primary Key.

J.Ja
Thanks for your answer Justin but I didn´t fix the problem yet. Could you give me more details ?  See what I did.
1) I deleted all rows from table
2) I created a new attribute test as int. After that I set it as identifier, fixed the errors on screens and published it. I got this error message at the end.
I think that delete the table on server could be the better option because the Outsystems could create it again from beginning. What do you think about that ? Do you know how to do that ?:

Database Upgrade Error

Could not create / change primary key in 'OSUSR_k1p_Funcionario' table. Inconsistent database table and entity primary key definitions.
If you don't care about the data. just delete the espace alltogether on the server (save it locally ofcourse)
and load the espace again and publish it.


If you already deleted all rows, you can equally delete the entity.
Recreate it with a different name and fix all reference errors.
Don't be too hasty changing it back to the original name. Only think of it after a successful deployment.
Statler, as beginner I didn´t know there was local and server espace. I researched a little more and could apply the steps you mentioned. It worked. Thanks so much. The problem will be when it comes to the production. Is there some procedure to do this there ?
what i did is to clone the application, change whatever you want to change before publishing. all data will be lost.