コード例 #1
0
ファイル: SyncGenerator.cs プロジェクト: VIKonst/DBSync
        private void UpdateTypes(SqlType source, SqlType destination)
        {
            StringBuilder text = new StringBuilder();

            foreach (SqlColumn column in destination.Columns)
            {
                text.AppendLine($"ALTER TABLE {column.ParentObject.QualifiedName} ALTER COLUMN [{column.Name}] {destination.GetTypeStatement()}");
            }
            text.AppendLine(destination.DropScript());
            text.AppendLine(source.CreateScript());
            foreach (SqlColumn column in destination.Columns)
            {
                text.AppendLine($"ALTER TABLE {column.ParentObject.QualifiedName} ALTER COLUMN [{column.Name}] {source.QualifiedName}");
            }

            _syncScript.Add(new SyncAction {
                Name = source.Name,
                Text = text.ToString(),
                Type = SyncActionType.AlterType
            }
                            );
        }