I am trying to use the Generate Database option to create two DDLs that will:
1. drop all FK and PK Constraints (By dependency order) and indexes.
2. create all PK and FK Constraints and indexes.
I do not want to drop tables.
After playing with all the available options, I was able to achieve the FKs and Indexes. I cannot see how to drop PKs without dropping the corresponding tables.
Help is welcome,
I'm not sure if this is possible through the Generate Database option. I think you will need to do a compare and merge, one with PK/FKs against one without, and then use that script.
Is there a macro to drop/create PK constraints ? or pre/post-sql ?
Here's a macro which should remove all PKs/FKs and relationships in the model:
Dim diag As Diagram
Dim mdl As Model
Dim submdl As SubModel
Dim ent As Entity
Dim attr As AttributeObj
Dim rel As Relationship
Dim idx As Index
Set diag = DiagramManager.ActiveDiagram
Set mdl = diag.ActiveModel
Set submdl = mdl.ActiveSubModel
For Each rel In mdl.Relationships
For Each ent In mdl.Entities
For Each attr In ent.Attributes
If attr.PrimaryKey = True Then
attr.PrimaryKey = False