Refactoring DB Table Names

Posts   
 
    
Marcus avatar
Marcus
User
Posts: 747
Joined: 23-Apr-2004
# Posted on: 12-Nov-2005 11:20:14   

Frans,

What happens when I change a table name in the database and refresh the catalog?

I have some refactoring to do which includes changing some table names. I seem to remember that the designer simply removes the Entities mapped to the removed table from the list... frowning and hence removes all my hard work in renaming and hiding the related fields etc...

Can you recommend a way to do this which has the least impact on the project file?

Can I hack the project file itself by simple directly changing the table / entity names and then do a refresh (remember DiskDoctor) ? smile

[edit] Could I use the ProjectInspector code to help make these changes?

Marcus

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 12-Nov-2005 13:16:09   

Marcus wrote:

Frans,

What happens when I change a table name in the database and refresh the catalog?

I have some refactoring to do which includes changing some table names. I seem to remember that the designer simply removes the Entities mapped to the removed table from the list... frowning and hence removes all my hard work in renaming and hiding the related fields etc...

I think it's good that you check out the new features added to the preferences in 1.0.2005.1 simple_smile Especially the settings which will show you a dialog in which you can select the targets for entities which targets are apparently not available (e.g. renamed wink ). LLBLGen Pro can find renamed tables btw, though if you don't want to rely on that, simply use that new feature. You should also take a look into the refresher preference which will sync names with target element names, like table/view names and field names automatically.

Can you recommend a way to do this which has the least impact on the project file?

Well, for everything: switch on the backup creation preference for the refresher. That way, you always have a backup for the situation when things go wrong.

Can I hack the project file itself by simple directly changing the table / entity names and then do a refresh (remember DiskDoctor) ? smile

[edit] Could I use the ProjectInspector code to help make these changes? Marcus

The projectinspector shows you the objectmodel indeed, the point is though that your catalog should be migrated as well. It's in general easier to rely on the features offered by the designer to get the mappings migrated. With the new preference (it's called 'ManuallySelectRenamedTargetsAfterRefresh') it's even easier and you won't run into the risk that entities got removed because the refresher can't find the target simple_smile

You can also do your refactorings of the db in multiple steps: - first rename the tables, refresh - check the mappings in the entity overview listing (rightclick on 'Entities', select 'View entity list') - if ok, proceed by removing/adding fields, fks etc. refresh.

Frans Bouma | Lead developer LLBLGen Pro
Marcus avatar
Marcus
User
Posts: 747
Joined: 23-Apr-2004
# Posted on: 12-Nov-2005 13:48:09   

Thanks I'll let you know how I get on... simple_smile

LukeO
User
Posts: 58
Joined: 23-Jul-2007
# Posted on: 15-Oct-2008 21:18:37   

I'm trying to do the same but with a typed view. I want to rename four typed views and just want to to tweak the db names as referenced in LLBLGEN. The LLBLGEN names will stay the same as well as the other custom settings. I just want to change the view name.

Is it possible?

Thanks, -Luke

Marcus wrote:

Thanks I'll let you know how I get on... simple_smile

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 16-Oct-2008 12:29:07   

Curently you'll have to re-add the TypedViews after renaming the database views and doing a catalog refresh. Then if you want to keep the old TypedView names, you'll have to rename them back.

P.S. Next time please open a new thread.

LukeO
User
Posts: 58
Joined: 23-Jul-2007
# Posted on: 16-Oct-2008 17:50:47   

Thanks. I will do that.

There is probably a fine line between adding to an existing thread (which I thought was related) and making a new thread. I tried to do my due dilgence and search all existing forums for an answer to my question before posing another one.

-Luke

Walaa wrote:

Curently you'll have to re-add the TypedViews after renaming the database views and doing a catalog refresh. Then if you want to keep the old TypedView names, you'll have to rename them back.

P.S. Next time please open a new thread.