//UNSAFE, not supported by MySQL: http://dev.mysql.com/doc/refman/5.1/en/rename-database.html //public override void RenameDatabase(string oldname, string newname) //{ // PutCmd("^rename ^database %i ^to %i", oldname, newname); //} public override void ChangeColumn(IColumnStructure oldcol, IColumnStructure newcol, IEnumerable <IConstraint> constraints) { Put("^alter ^table %f ^change ^column %i %i ", oldcol.Table, oldcol.ColumnName, newcol.ColumnName); ColumnDefinition(newcol, true, true, true); InlineConstraints(constraints); EndCommand(); }
public override void ChangeColumn(IColumnStructure oldcol, IColumnStructure newcol, IEnumerable <IConstraint> constraints) { if (oldcol.ColumnName != newcol.ColumnName) { PutCmd("^alter ^table %f ^rename ^column %i ^to %i", oldcol.Table, oldcol.ColumnName, newcol.ColumnName); } if (!DbDiffTool.EqualTypes(oldcol.DataType, newcol.DataType, new DbDiffOptions())) { PutCmd("^alter ^table %f ^alter ^column %i ^type %s", newcol.Table, newcol.ColumnName, m_dialect.GenericTypeToSpecific(newcol.DataType)); } if (oldcol.IsNullable != newcol.IsNullable) { if (newcol.IsNullable) { PutCmd("^alter ^table %f ^alter ^column %i ^drop ^not ^null", newcol.Table, newcol.ColumnName); } else { PutCmd("^alter ^table %f ^alter ^column %i ^set ^not ^null", newcol.Table, newcol.ColumnName); } } if (oldcol.DefaultValue.SafeGetSql(m_dialect) != newcol.DefaultValue.SafeGetSql(m_dialect)) { if (newcol.DefaultValue == null) { PutCmd("^alter ^table %f ^alter ^column %i ^drop ^default", newcol.Table, newcol.ColumnName); } else { PutCmd("^alter ^table %f ^alter ^column %i ^set ^default %s", newcol.Table, newcol.ColumnName, newcol.DefaultValue.SafeGetSql(m_dialect)); } } this.CreateConstraints(constraints); }
public virtual void ColumnDefinition(IColumnStructure col, bool includeDefault, bool includeNullable, bool includeCollate) { if (m_dialect.DialectCaps.Domains && col.Domain != null && m_props.UseDomains) { Put("%f", col.Domain); } else { WriteRaw(m_dialect.GenericTypeToSpecific(col.DataType).ToString()); } WriteRaw(" "); if (includeNullable) { WriteRaw(col.IsNullable ? "NULL" : "NOT NULL"); } if (includeCollate && m_dialect.SupportsColumnCollation(col.DataType) && !String.IsNullOrEmpty(col.Collation) && AllowWriteColumnCollation()) { WriteRaw(" COLLATE "); WriteRaw(col.Collation); } if (includeDefault && col.DefaultValue != null) { ColumnDefinition_Default(col); } }
public override void RenameColumn(IColumnStructure column, string newcol) { var newcoldef = new ColumnStructure(column); newcoldef.ColumnName = newcol; this.ChangeColumn(column, newcoldef); }
public override void ChangeColumn(IColumnStructure oldcol, IColumnStructure newcol, IEnumerable <IConstraint> constrains) { if (oldcol.ColumnName != newcol.ColumnName) { RenameColumn(oldcol, newcol.ColumnName); } if (oldcol.IsNullable != newcol.IsNullable) { PutCmd("^alter ^table %f ^modify %i %k", newcol.Table, newcol.ColumnName, newcol.IsNullable ? "null" : "not null"); } if (!DbDiffTool.EqualDefaultValues(oldcol, newcol)) { if (newcol.DefaultValue == null) { PutCmd("^alter ^table %f ^modify %i ^default ^null", newcol.Table, newcol.ColumnName); } else { Put("^alter ^table %f ^modify %i ", newcol.Table, newcol.ColumnName); ColumnDefinition_Default(newcol); this.EndCommand(); } } if (!DbDiffTool.EqualTypes(oldcol.DataType, newcol.DataType, new DbDiffOptions())) { Put("^alter ^table %f ^modify %i ", newcol.Table, newcol.ColumnName); ColumnDefinition(newcol, false, false, false); } EndCommand(); }
public void LoadFromTransform(IRowTransform tr) { lbtarget.Rows.Clear(); if (tr is IdentityTransform) { foreach (IColumnStructure col in m_srcformat.Columns) { lbtarget.Rows.Add(col.ColumnName, new GenericTransform.ColumnColExprType().ToString(), col.ColumnName); } } if (tr is PermuteTransform) { var t = tr as PermuteTransform; foreach (int i in t.DestIndexes) { IColumnStructure col = m_srcformat.Columns[i]; lbtarget.Rows.Add(col.ColumnName, new GenericTransform.ColumnColExprType().ToString(), col.ColumnName); } } if (tr is GenericTransform) { var t = tr as GenericTransform; foreach (var col in t.DestCols) { lbtarget.Rows.Add(col.Name, col.Type.ToString(), col.Expression); } } }
public virtual void CreateColumn(IColumnStructure col, IEnumerable <IConstraint> constrains) { Put("^alter ^table %f add %i ", col.Table, col.ColumnName); ColumnDefinition(col, true, true, true); InlineConstraints(constrains); EndCommand(); }
public virtual void ChangeColumn(IColumnStructure oldcol, IColumnStructure newcol, IEnumerable <IConstraint> constrains) { Put("/*^alter ^table %f ^change ^column %i %i ", oldcol.Table, oldcol.ColumnName, newcol.ColumnName); ColumnDefinition(newcol, true, true, true); Put("*/"); EndCommand(); }
public override void NotifyDropColumn(IColumnStructure column) { if (FullName == column.Table.FullName) { _Columns.RemoveIf(c => c.ColumnName == column.ColumnName); } }
public void DropColumn(IColumnStructure column) { ColumnStructure col = Structure.FindOrCreateColumn(column); AddOperation(new AlterOperation_DropColumn { ParentTable = (TableStructure)col.Table, OldObject = col }); }
public override void NotifyDropColumn(IColumnStructure column) { base.NotifyDropColumn(column); if (PrimaryKeyTable == column.Table) { PrimaryKeyColumns.RemoveIf(c => c.ColumnName == column.ColumnName); } }
public void RenameColumn(IColumnStructure column, string name) { ColumnStructure col = Structure.FindOrCreateColumn(column); AddOperation(new AlterOperation_RenameColumn { OldObject = col, ParentTable = (TableStructure)col.Table, NewName = new NameWithSchema(name) }); }
public void ChangeColumn(IColumnStructure column, IColumnStructure newcolumn) { ColumnStructure col = Structure.FindOrCreateColumn(column); AddOperation(new AlterOperation_ChangeColumn { OldObject = col, ParentTable = (TableStructure)col.Table, NewObject = new ColumnStructure(newcolumn) }); }
public void RenameColumn(IColumnStructure column, string newcol) { string oldcol = column.ColumnName; foreach (AbstractObjectStructure obj in this.GetAllObjects()) { obj.NotifyRenameColumn(column.Table.FullName, oldcol, newcol); } }
public override void ColumnDefinition_Default(IColumnStructure col) { string defsql = col.DefaultValue.GenerateSql(m_dialect, col.DataType, null); if (defsql != null) { Put(" ^constraint %i ^default %s ", GuessDefaultName(col), defsql); } }
public void RenameColumn(string oldName, string newName) { IColumnStructure oldCol = _Columns.First(c => c.ColumnName == oldName); foreach (AbstractObjectStructure obj in this.GetAllObjects()) { obj.NotifyRenameColumn(FullName, oldCol.ColumnName, newName); } }
private void DropDefault(IColumnStructure col) { string defname = col.GetSpecificAttribute("mssql", "defname"); if (defname != null) { PutCmd("^alter ^table %f ^drop ^constraint %i", col.Table, defname); } }
public void ChangeColumn(IColumnStructure oldcol, IColumnStructure newcol, IEnumerable <IConstraint> constraints) { var col = this.FindColumn(oldcol) as ColumnStructure; col.AssignFrom(newcol); this.CreateConstraints(constraints); //if (oldcol.ColumnName != newcol.ColumnName) RenameColumn(oldcol, newcol.ColumnName); //FindTable(oldcol.Table.FullName).ChangeColumnDefinition(newcol); //foreach (AbstractObjectStructure obj in this.GetAllObjects()) obj.NotifyChangeColumnType_RefsOnly(newcol); }
public static string GetSpecificAttribute(this IColumnStructure col, string dialect, string name) { string key = dialect + "." + name; if (col.SpecificData.ContainsKey(key)) { return(col.SpecificData[key]); } return(null); }
public virtual DbTypeBase MigrateDataType(IColumnStructure owningColumn, DbTypeBase type, IMigrationProfile profile, IProgressInfo progress) { ISpecificType spectype = GenericTypeToSpecific(type, profile, progress); //if (!DialectCaps.Arrays && type.ArraySpec.IsArray) //{ // return new DbTypeText(); // migrate arrays as text blob //} return(spectype.ToGenericType()); }
public virtual void ColumnDefinition_Default(IColumnStructure col) { string defsql = col.DefaultValue.GenerateSql(m_dialect, col.DataType, null); if (defsql != null) { WriteRaw(" DEFAULT "); WriteRaw(defsql); } }
public override DbTypeBase MigrateDataType(IColumnStructure owningColumn, DbTypeBase type, IMigrationProfile profile, IProgressInfo progress) { if (type is DbTypeString && ((DbTypeString)type).Length <= 0) { // convert to BLOB variant, MySQL doesn't support varchar(max) notation return(((DbTypeString)type).ConvertToBlobVariant()); } return(base.MigrateDataType(owningColumn, type, profile, progress)); }
private string GuessDefaultName(IColumnStructure col) { string defname = col.GetSpecificAttribute("mssql", "defname"); if (defname == null) { defname = String.Format("DF_{0}_{1}_{2}", col.Table.FullName.Schema ?? "dbo", col.Table.FullName.Name, col.ColumnName); } return(defname); }
//public override void RenameTable(NameWithSchema oldName, string newName) //{ // PutCmd("^rename ^table %i ^to %i", oldName.Name, newName); //} public override void ChangeColumn(IColumnStructure oldcol, IColumnStructure newcol, IEnumerable <IConstraint> constraints) { if (oldcol.ColumnName != newcol.ColumnName) { throw new Exception("DAE-00317 operation not supported"); } Put("^alter ^table %f ^alter ^column %i ", oldcol.Table, newcol.ColumnName); ColumnDefinition(newcol, false, true, true); EndCommand(); this.CreateConstraints(constraints); }
public ColumnStructure AddColumn(IColumnStructure source, bool reuseGrouId) { ColumnStructure col = new ColumnStructure(source); if (!reuseGrouId) { col.GroupId = Guid.NewGuid().ToString(); } _Columns.Add(col); return(col); }
public void LoadFromTransform(IRowTransform tr) { bool[] activeCols = new bool[m_target.Columns.Count]; if (tr is IdentityTransform) { for (int i = 0; i < m_combos.Count; i++) { activeCols[i] = true; int srcindex = m_source.Columns.GetIndex(m_target.Columns[i].ColumnName); if (srcindex >= 0) { SetColumnBindings(i, new GenericTransform.ColumnColExprType(), m_source.Columns[srcindex].ColumnName); } } } if (tr is PermuteTransform) { var t = tr as PermuteTransform; for (int i = 0; i < t.OutputFormat.Columns.Count; i++) { var dstcol = t.OutputFormat.Columns[i]; int dsti = m_target.Columns.GetIndex(dstcol.ColumnName); if (dsti < 0) { continue; } int srci = t.DestIndexes[i]; IColumnStructure srccol = m_source.Columns[srci]; SetColumnBindings(dsti, new GenericTransform.ColumnColExprType(), srccol.ColumnName); activeCols[dsti] = true; } } if (tr is GenericTransform) { var t = tr as GenericTransform; for (int i = 0; i < t.OutputFormat.Columns.Count; i++) { var dstcol = t.OutputFormat.Columns[i]; int dsti = m_target.Columns.GetIndex(dstcol.ColumnName); if (dsti < 0) { continue; } var d = t.DestCols[i]; SetColumnBindings(dsti, d.Type, d.Expression); activeCols[dsti] = true; } } for (int i = 0; i < activeCols.Length; i++) { m_checks[i].Checked = !activeCols[i]; } }
private void CreateDefault(IColumnStructure col) { if (col.DefaultValue == null) { return; } string defsql = col.DefaultValue.GenerateSql(m_dialect, col.DataType, null); if (defsql != null) { PutCmd("^alter ^table %f ^alter ^column %i ^set ^default %s", col.Table, col.ColumnName, defsql); } }
public ColumnStructure(IColumnStructure src) : base(src) { m_columnName = src.ColumnName; m_dataType = src.DataType.Clone(); m_isNullable = src.IsNullable; m_defaultValue = src.DefaultValue; m_characterSet = src.CharacterSet; m_collation = src.Collation; SpecificData.AddAll(src.SpecificData); //TableName = src.Table; //Table = src.Table; Domain = src.Domain; }
private void CreateDefault(IColumnStructure col) { if (col.DefaultValue == null) { return; } string defsql = col.DefaultValue.GenerateSql(m_dialect, col.DataType, null); if (defsql != null) { var defname = GuessDefaultName(col); PutCmd("^alter ^table %f ^add ^constraint %i ^default %s for %i", col.Table, defname, defsql, col.ColumnName); } }
public void DropColumn(IColumnStructure column) { ColumnStructure colcopy = new ColumnStructure(column); colcopy.SetDummyTable(column.Table.FullName); // we must send copy of column, because when dropping column, column.Table will be null foreach (AbstractObjectStructure obj in this.GetAllObjects()) { obj.NotifyDropColumn(colcopy); } foreach (TableStructure tbl in Tables) { tbl.DropEmptyConstraints(); } }