Versioning problem?

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
1/9/2011 8:38:23 AM
bob
Gravatar
Total Posts 126
YAF developer

Versioning problem?

1. Trying to add a module. I need 11 scripts to add.

When I add 0.0.0.1 - 0.0.0.9. and then 0.0.1.1 the last one executed and fails of cause.

If it's 0.0.2.1 then it executes first.

One of the latests repos.

2. When I execute a script file which begins with

if not exists (select top 1 1 from sysobjects where id = object_id(N'[{databaseOwner}].[{objectQualifier}Thanks]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
CREATE TABLE [{databaseOwner}].[{objectQualifier}Thanks](
[ThanksID] [int] IDENTITY(1,1) NOT NULL,
[ThanksFromUserID] [int] NOT NULL,
[ThanksToUserID] [int] NOT NULL,
[MessageID] [int] NOT NULL,
[ThanksDate] [smalldatetime] NOT NULL
constraint [PK_{objectQualifier}Thanks] primary key(ThanksID)
)
go

/* YAF Buddy Table */
if not exists (select top 1 1 from sysobjects where id = object_id(N'[{databaseOwner}].[{objectQualifier}Buddy]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
CREATE TABLE [{databaseOwner}].[{objectQualifier}Buddy](
[ID] [int] IDENTITY(1,1) NOT NULL,
[FromUserID] [int] NOT NULL,
[ToUserID] [int] NOT NULL,
[Approved] [bit] NOT NULL,
[Requested] [datetime] NOT NULL
constraint [PK_{objectQualifier}Buddy] primary key(ID)
)
go

.....

It fails...

Executing script YAFModule - 0.0.2.1 - 00:00:34.7309865
System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near the keyword 'if'. Incorrect syntax near the keyword 'if'. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at mojoPortal.Data.SqlHelper.ExecuteNonQuery(SqlTransaction transaction, CommandType commandType, String commandText, Int32 commandTimeout, SqlParameter[] commandParameters) in C:\Users\Vladimir\Projects\mojoportal_mssqlyaf\mojoPortal.Data.MSSQL\SqlHelper.cs:line 154 at mojoPortal.Data.SqlHelper.ExecuteNonQuery(SqlTransaction transaction, CommandType commandType, String commandText, SqlParameter[] commandParameters) in C:\Users\Vladimir\Projects\mojoportal_mssqlyaf\mojoPortal.Data.MSSQL\SqlHelper.cs:line 113 at mojoPortal.Data.DBPortal.DatabaseHelperRunScript(String script, String overrideConnectionInfo)

1/9/2011 9:01:23 AM
Gravatar
Total Posts 18439

Re: Versioning problem?

Hi Bob,

1. It should only run scripts in script order, it records scripts that are success by incrementing the row in the mp_SchemVersion table, it will never run a script with a version lower to or equal the version recorded there.

2. What are these tokens in your script 

  • {databaseOwner}
  • {objectQualifier}

those are not correct and mojoPortal is not replacing those tokens with any values, maybe that is something used in YAF setup but needs to be changed, probably just replace the first one with dbo and the second with some prefix other than mp_ so it is clear it is not a core mojo table, maybe myaf_ would be good.

Really because of our versioning of scripts you don't need to check if the table exists and can assume it is does not unless the script runs success then assume it does, this can simplify the script if all else fails. Main thing is to pick table names that are not likely to clash and the prefix can help.

Best,

Joe

1/9/2011 10:34:43 AM
bob
Gravatar
Total Posts 126
YAF developer

Re: Versioning problem?

1.Hm... I've forgotten how it works in MojoPortal. Thanks, Joe.

2. Oh yes, my bad, I'll check it again.

P.S. I'm writing a simple configurable WinForms application which will help a lot to keep it going when a new version appears and some bugs can appear. I was sure that the replacement still works fine, didn't look  at the script :(

 

You must sign in to post in the forums. This thread is closed to new posts.