//public static void RecreateName(this IConstraint cnt) //{ // if (cnt is IPrimaryKey) cnt.Name = PkName(cnt.Table); // else if (cnt is ForeignKey) cnt.Name = FkName(cnt.Table, ((ForeignKey)cnt).Columns); // else if (cnt is CheckConstraint) cnt.Name = CheckName(cnt.Table); // else if (cnt is UniqueConstraint) cnt.Name = UniqueName(cnt.Table, ((UniqueConstraint)cnt).Columns); //} public static void RenameTable(TableStructure tbl, IEnumerable tables, NameWithSchema newname) { var oldname = tbl.FullName; tbl.FullName = newname; foreach (TableStructure t in tables) { foreach (Constraint cnt in t.Constraints) { var fk = cnt as ForeignKey; if (fk != null) { if (fk.PrimaryKeyTable == oldname) { fk.PrimaryKeyTable = newname; if (fk.Columns.Count == 1 && fk.Columns[0].ColumnName.StartsWith(oldname.Name)) { string postfix = fk.Columns[0].ColumnName.Substring(oldname.Name.Length); fk.Columns[0] = new ColumnReference(newname.Name + postfix); ((ColumnStructure)t.Columns[oldname.Name + postfix]).ColumnName = newname.Name + postfix; } fk.Name = DbObjectNameTool.ConstraintName(fk); } } } } foreach (Constraint cnt in tbl.Constraints) { //cnt.Table = newname; cnt.Name = DbObjectNameTool.ConstraintName(cnt); } }
protected virtual Constraint MigrateConstraintOrIndex(Constraint cnt, IMigrationProfile profile, IProgressInfo progress) { if (cnt is IPrimaryKey) { if (DialectCaps.AnonymousPrimaryKey) { PrimaryKey pk = (PrimaryKey)cnt; pk.Name = DbObjectNameTool.PkName(pk.Table.FullName); } } return(cnt); }
internal override string DoCreateName(ISqlDialect dialect) { if (dialect != null && dialect.DialectCaps.AnonymousPrimaryKey && Type == EditorIndexOrKeyType.PrimaryKey) { return(null); } switch (Type) { case EditorIndexOrKeyType.PrimaryKey: return(DbObjectNameTool.PkName(m_table)); case EditorIndexOrKeyType.Index: return(DbObjectNameTool.IndexName(m_table, m_columns)); case EditorIndexOrKeyType.UniqueConstraint: return(DbObjectNameTool.UniqueName(m_table, m_columns)); } throw new InternalError("DAE-00176 internal error"); }
internal override string DoCreateName(ISqlDialect dialect) { return(m_frame.GetUniqueName(DbObjectNameTool.CheckName(m_table))); }
internal override string DoCreateName(ISqlDialect dialect) { return(DbObjectNameTool.FkName(m_table, from col in m_columns select(IColumnReference) col.SrcName)); }
public override string RenameConstraint(IConstraint constraint) { return(DbObjectNameTool.ConstraintName(constraint)); }