Creating a table using system setup

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
11/22/2010 11:56:45 AM
Gravatar
Total Posts 22

Creating a table using system setup

Hi Joe,

Im just working my way through the dev tutorials. Thanks a mil for creating. They really are a great help.

I am having problems however in tutorial 10 - creating a table using system setup. I created the table and created the script which i saved in the SchemaInstallScripts folder. The script is copied to web/setup/applications as expected post build.

However when i re-run the setup page the script dose not run. Any idea's why this is happening. When I created the script for stored procedures in the next tutorial the script ran as expected during setup.

I have been able to continue but I really would like to get this sorted so I know for future reference where the problem lies.

Any help would be greatly appreciated.

Cheers

Keith

11/22/2010 12:40:56 PM
Gravatar
Total Posts 245
mojoPortal Community Expert

Re: Creating a table using system setup

My table scripts are in:

Setup
   applications
      myapplication
         SchemaInstallScripts
            mssql  
               0.0.0.1.config

Here's a snippet of my table Create

SET NOCOUNT ON
GO
 -- Definition for table DOC_BUSINESS_PROCESS :
--
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
 
CREATE TABLE [dbo].[DOC_BUSINESS_PROCESS] (
[BPGuid] uniqueidentifier DEFAULT newid() NOT NULL,
[SiteGuid] uniqueidentifier NOT NULL,
[ModuleGuid] uniqueidentifier NOT NULL,
[BPName] varchar(100) COLLATE Latin1_General_CI_AS NOT NULL,
[DeptGuid] uniqueidentifier NOT NULL,
[HlinkProcess] uniqueidentifier NULL,
[HlinkProcessMap] uniqueidentifier NULL,
[Created] datetime DEFAULT getutcdate() NOT NULL,
[CreatedBy] uniqueidentifier NOT NULL,
[LastModified] datetime NULL,
[LastModifedBy] uniqueidentifier NULL
)
ON [PRIMARY]
GO
 
--
-- Definition for table DOC_BUSINESS_PROCESS_RULE :
--
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
 
CREATE TABLE [dbo].[DOC_BUSINESS_PROCESS_RULE] (
[BPRGuid] uniqueidentifier DEFAULT newid() NOT NULL,
[SiteGuid] uniqueidentifier NOT NULL,
[ModuleGuid] uniqueidentifier NOT NULL,
[BPGuid] uniqueidentifier NOT NULL,
[BRGuid] uniqueidentifier NOT NULL,
[Created] datetime DEFAULT getutcdate() NOT NULL,
[CreatedBy] uniqueidentifier NOT NULL,
[LastModified] datetime NULL,
[LastModifedBy] uniqueidentifier NULL
)
ON [PRIMARY]
GO

Then I add my stored procedures and functions in SchemaUpgradelScripts\mssql\ starting with 0.0.0.2.config, then 0.0.0.3.config, then 0.0.0.4.config
I use several files to separate things.  Makes for easier debugging.

Hope this helps

Arvixe.com

11/22/2010 2:33:03 PM
Gravatar
Total Posts 22

Re: Creating a table using system setu

Thanks Rick,

I am using the folder structure you described above. However when setup runs it just dose not see the script. My scripts for stored procs ran no with no problems. I checked the script in query analyzer so I know thats not the prob and anyhow I would expect an error during setup if the script ran and failed.

Any idea why setup is not picking up the script. Starting to pull my hair out over this.

 

11/22/2010 2:43:23 PM
Gravatar
Total Posts 550

Re: Creating a table using system setup

Hi ,

Please see mp_SchemaVersion for any row with you scripts folder, and check last version of it. If not exists any row for your scripts folder let me know.

hope helps

Asad

11/22/2010 2:56:02 PM
Gravatar
Total Posts 245
mojoPortal Community Expert

Re: Creating a table using system setup

I see where Asad is going with this and then I re-read your post Keith.  It says  re-run setup.  AHhhhhh.............

Before you pull your hair out try your scripts on a fresh empty database because they only run once and are added to the mp_SchemaVersion table so that setup knows NOT to run them again.

Arvixe.com

Rick

11/22/2010 3:23:52 PM
Gravatar
Total Posts 1204
Proud member of the mojoPortal team

Help support mojoPortal!
Add-on modules

Re: Creating a table using system setup

I always keep a SQL script handy during feature development, that can drop/alter my table(s) and clear the feature entry from the mp_SchemaVersion table if needed. It makes for a much quicker turnaround time when I want to test the create or update script multiple times.

11/22/2010 3:36:01 PM
Gravatar
Total Posts 22

Re: Creating a table using system setup

Thanks Rick and Asad

I changed the application name in the mp_SchemaVersion table and the script ran as expected when setup was re-run. Hopefully this wont cause too many problems going forward.

Thanks again for your help

Keith

11/22/2010 4:29:43 PM
Gravatar
Total Posts 245
mojoPortal Community Expert

Re: Creating a table using system setup

I always keep a SQL script handy during feature development, that can drop/alter my table(s) and clear the feature entry from the mp_SchemaVersion table if needed. It makes for a much quicker turnaround time when I want to test the create or update script multiple times.

Thanks Jamie

I wish I'd have thought of that.  It would have saved me a ton of time the last few weeks.

11/23/2010 7:20:00 AM
Gravatar
Total Posts 22

Re: Creating a table using system setup

Thanks Jamie. Great idea.

Quick question though. Is it just mp_SchemaVersion and mp_SchemaScriptHistory I need to delete entries from or are there more i should include in a script?

11/23/2010 10:15:20 AM
Gravatar
Total Posts 1204
Proud member of the mojoPortal team

Help support mojoPortal!
Add-on modules

Re: Creating a table using system setup

Yep, those are the only mojoPortal tables I had to work with. Other than that it was just changes to my own tables.

Jamie

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