Is there a way to rebuild indices for all the classes in a given namespace?
I'm moving *D globals from DatabaseA to DatabalseB.
After importing globals I need to rebuild indices for all the imported persistent classes.
Colleagues, maybe you know one command which does it for all the classes in Namespace?
Comments
There is no such command. I would recommend moving the index global as well. However, if this is not an option then you probably want to do something like:
USER>s sql="select Name from %Dictionary.CompiledClass where system=0 and NOT(Name %Startswith '%') AND SUPER [ 'Persistent'"
USER>s rs=##class(%SQL.Statement).%ExecDirect(,sql)
USER>while rs.%Next() { s sc= $classmethod(rs.%GetData(1),"%BuildIndices") w "Built "_rs.%GetData(1)_" with return code = "_sc,! }Obviously this is kind of hacked together and you'll want to clean it up, but the outline is there. I had to make some assumptions like you don't have any other classes in your application that have 'Persistent' in them. If you do then you'll want (Super [ '%Library.Persistent' OR Super [ '%Persistent'). Since classes are case sensitive this should be fine.
Thanks, Kyle!
Speaking of assumptions, should I filter the mapped classes as well?