orchard 1.0.20 to 1.1 menu 1.0 to 1.2.1 migration error

Topics: General, Installing Orchard
Apr 26, 2011 at 2:30 PM

Hello it's me again. I get error Invalid object name 
'Szmyd_Orchard_Modules_Menu_AdvancedMenuPartRecord'
This happened after upgrading Orchard from 1.0.20 to 1.1 with old version of menu. After upgrading to 1.1 old menu would not load, so I deleted module and tried to get new version (1.2.1) from gallery, Install was ok, but after enabling feature I got this error. Tried removing everything and even deleting 4 tables in DB (from old version) then downloading the new one (1.2.1). Same error. It looks like for some reason new tables are not created in DB. When I set breakpoint in Migrations.cs -> Create() it's not being hit, someone must have solved this on by now. Please share.

Apr 26, 2011 at 3:39 PM
Edited Apr 26, 2011 at 3:47 PM

extraordinary solution :)

1. Make DB backup :) go to SQL Management Studio. Select Expand Server -> Databases -> Orchard database -> right mouse button -> tasks-> detach. Then to your SQL install dir usually  C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA 

or wherever your orchard DB is stored and copy it somewhere like desktop or whatever;.

2.Attach DB which you jest detached

create by hand table 

Szmyd_Orchard_Modules_Menu_AdvancedMenuPartRecord

with Columns

Id int Primary Key

Name nvarchar(255)

3. Run Orchard, go to Admin. Everything in the Admin panel will load (no more Err)

4. (don't click yet)

go to Modules ->Navigation

  • Advanced menu 

it should require update all red and stuff. (don't click update yet)

5. go to SQL DB and delete all the tables starting with

Szmyd (should be 5) (yes including the table you created second ago) 

6. after delete click on Update Advanced menu Module in Admin panel

7. TADA! menu 1.2.1 :) or some error which I didn't get then MEGA FAIL ;(

 

Apr 26, 2011 at 4:25 PM
Edited Apr 26, 2011 at 4:27 PM

You think all done? 

Think again :)

After creating new menu 'Top Menu'

(menu gets created)

I try to fill it with existing items

but

 

  public ActionResult Fill(string menuName, bool containable)
        {
            if (!_services.Authorizer.Authorize(Permissions.EditMenus, T("Couldn't fill the menu")))
                return new HttpUnauthorizedResult();

            var menu = _menuService.GetMenu(menuName);

 

menu == null.

I checked and record is in DB

Id Name 139 Top Menu

Anyone had similar problem? Please share.

Developer
Apr 26, 2011 at 6:27 PM

Hi!

I'm in the process of building the next release and will try to fix all the reported errors.

The problem with DB is that even after complete uninstallation (removing all files and tables in DB) Orchard keeps track of data migration number (it makes updating possible and easy). So when you try to reinstall it again, Orchard won't fire data migration methods (and tables won't be created) from the beginning (starting from Create() one). You have to reset this counter (this is the case with all modules, not specific for the menu one) - remove the record holding it.

This data is stored in Orchard_Framework_DataMigrationRecord table. If you delete the record with DataMigrationClass field equal to "Szmyd.Orchard.Modules.Menu.Migrations" the uninstallation will be complete and you are free to reinstall the module again. I guess it should happen automatically - I'll open an issue for that btw.

HTH

Cheers, Piotr

Apr 27, 2011 at 12:28 PM

Thank you very much.

I am now rebuilding ExportSitemapXml 

is there a way to call Menu list from static method 

I need something like 

 public static SelectList GetMenuList(string SELECTED) {
            MenuService ms = new MenuService();  
            return new SelectList(ms.GetMenus().Select(o=>new SelectListItem{
            Text = o.Name,
            Value = o.Name
            }),"Text","Value",SELECTED);
        }
for user to be able to choose which menu for he needs to build XML.