public void DoNewValueTypePropertyList(ObjectClass objClass, ValueTypeProperty prop) { if (!PreMigration(PropertyMigrationEventType.Add, null, prop)) return; Log.InfoFormat("New ValueType Property List: {0}", prop.Name); CheckValueTypePropertyHasWarnings(prop); var tblName = db.GetTableName(prop.Module.SchemaName, prop.GetCollectionEntryTable()); string fkName = Construct.ForeignKeyColumnName(prop); string valPropName = prop.Name; string valPropIndexName = prop.Name + "Index"; string assocName = prop.GetAssociationName(); bool hasPersistentOrder = prop.HasPersistentOrder; db.CreateTable(tblName, true); db.CreateColumn(tblName, fkName, System.Data.DbType.Int32, 0, 0, false); db.CreateColumn(tblName, valPropName, prop.GetDbType(), prop.GetSize(), prop.GetScale(), false, SchemaManager.GetDefaultConstraint(prop)); 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, prop); }
public void DoNewValueTypePropertyList(ObjectClass objClass, ValueTypeProperty prop) { Log.InfoFormat("New ValueType Property List: {0}", prop.Name); var tblName = db.GetTableName(prop.Module.SchemaName, prop.GetCollectionEntryTable()); string fkName = prop.GetCollectionEntryReverseKeyColumnName(); string valPropName = prop.Name; string valPropIndexName = prop.Name + "Index"; string assocName = prop.GetAssociationName(); bool hasPersistentOrder = prop.HasPersistentOrder; db.CreateTable(tblName, true); db.CreateColumn(tblName, fkName, System.Data.DbType.Int32, 0, 0, false); db.CreateColumn(tblName, valPropName, prop.GetDbType(), prop.GetSize(), prop.GetScale(), false, SchemaManager.GetDefaultConstraint(prop)); 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 DoDeleteValueTypePropertyList(ObjectClass objClass, ValueTypeProperty savedProp, string prefix) { if (!PreMigration(PropertyMigrationEventType.Delete, savedProp, null)) return; Log.InfoFormat("Delete ValueType Property List: {0}", savedProp.Name); var tblName = db.GetTableName(savedProp.Module.SchemaName, savedProp.GetCollectionEntryTable()); db.DropTable(tblName); PostMigration(PropertyMigrationEventType.Delete, savedProp, null); }