public void DoNewCompoundObjectPropertyList(ObjectClass objClass, CompoundObjectProperty cprop) { Log.InfoFormat("New CompoundObject Property List: {0}", cprop.Name); var tblName = db.GetTableName(cprop.Module.SchemaName, cprop.GetCollectionEntryTable()); string fkName = "fk_" + cprop.ObjectClass.Name; // TODO: Support neested CompoundObject string valPropIndexName = cprop.Name + "Index"; string assocName = cprop.GetAssociationName(); bool hasPersistentOrder = cprop.HasPersistentOrder; db.CreateTable(tblName, true); db.CreateColumn(tblName, fkName, System.Data.DbType.Int32, 0, 0, false); foreach (ValueTypeProperty p in cprop.CompoundObjectDefinition.Properties) { db.CreateColumn(tblName, Construct.NestedColumnName(p.Name, cprop.Name), p.GetDbType(), p.GetSize(), p.GetScale(), true, SchemaManager.GetDefaultConstraint(cprop)); } if (hasPersistentOrder) { db.CreateColumn(tblName, valPropIndexName, System.Data.DbType.Int32, 0, 0, false); } db.CreateFKConstraint(tblName, db.GetTableName(objClass.Module.SchemaName, objClass.TableName), fkName, assocName, true); db.CreateIndex(tblName, Construct.IndexName(tblName.Name, fkName), false, false, fkName); }
public void DoNewCompoundObjectPropertyList(ObjectClass objClass, CompoundObjectProperty cprop) { if (!PreMigration(PropertyMigrationEventType.Add, null, cprop)) return; Log.InfoFormat("New CompoundObject Property List: {0}", cprop.Name); var tblName = db.GetTableName(cprop.Module.SchemaName, cprop.GetCollectionEntryTable()); string fkName = Construct.ForeignKeyColumnName(cprop); // TODO: Support nested CompoundObject string valPropIndexName = cprop.Name + "Index"; string assocName = cprop.GetAssociationName(); bool hasPersistentOrder = cprop.HasPersistentOrder; db.CreateTable(tblName, true); db.CreateColumn(tblName, fkName, System.Data.DbType.Int32, 0, 0, false); foreach (ValueTypeProperty p in cprop.CompoundObjectDefinition.Properties) { CheckValueTypePropertyHasWarnings(p); db.CreateColumn(tblName, Construct.ColumnName(p, cprop.Name), p.GetDbType(), p.GetSize(), p.GetScale(), true, null); } if (hasPersistentOrder) { db.CreateColumn(tblName, valPropIndexName, System.Data.DbType.Int32, 0, 0, false); } db.CreateFKConstraint(tblName, objClass.GetTableRef(db), fkName, assocName, true); db.CreateIndex(tblName, Construct.IndexName(tblName.Name, fkName), false, false, fkName); PostMigration(PropertyMigrationEventType.Add, null, cprop); }