/*public List<ISchemaBase> FindAllByColumn(String ColumnName) * { * this.t * }*/ public override SQLScriptList ToSqlDiff() { var listDiff = new SQLScriptList(); listDiff.Add("USE [" + Name + "]\r\nGO\r\n\r\n", 0, Enums.ScripActionType.UseDatabase); listDiff.AddRange(Assemblies.ToSqlDiff()); listDiff.AddRange(Defaults.ToSqlDiff()); listDiff.AddRange(UserTypes.ToSqlDiff()); listDiff.AddRange(TablesTypes.ToSqlDiff()); listDiff.AddRange(Tables.ToSqlDiff()); listDiff.AddRange(Rules.ToSqlDiff()); listDiff.AddRange(Schemas.ToSqlDiff()); listDiff.AddRange(XmlSchemas.ToSqlDiff()); listDiff.AddRange(Procedures.ToSqlDiff()); listDiff.AddRange(CLRProcedures.ToSqlDiff()); listDiff.AddRange(CLRFunctions.ToSqlDiff()); listDiff.AddRange(FileGroups.ToSqlDiff()); listDiff.AddRange(DDLTriggers.ToSqlDiff()); listDiff.AddRange(Synonyms.ToSqlDiff()); listDiff.AddRange(Views.ToSqlDiff()); listDiff.AddRange(Users.ToSqlDiff()); listDiff.AddRange(Functions.ToSqlDiff()); listDiff.AddRange(Roles.ToSqlDiff()); listDiff.AddRange(PartitionFunctions.ToSqlDiff()); listDiff.AddRange(PartitionSchemes.ToSqlDiff()); listDiff.AddRange(FullText.ToSqlDiff()); return(listDiff); }
public override SQLScriptList ToSqlDiff(ICollection <ISchemaBase> schemas) { var isAzure10 = this.Info.Version == DatabaseInfo.SQLServerVersion.SQLServerAzure10; var listDiff = new SQLScriptList(); var header = $@"/* OpenDBDiff {System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()} https://github.com/OpenDBDiff/OpenDBDiff Script created by {Environment.UserDomainName}\{Environment.UserName} on {DateTime.Now.ToShortDateString()} at {DateTime.Now.ToLongTimeString()}. Created on: {Environment.MachineName} Source: {SourceInfo?.Database ?? "Unknown"} on {SourceInfo?.Server ?? "Unknown"} Destination: {Info?.Database ?? "Unknown"} on {Info?.Server ?? "Unknown"} ### This script performs actions to change the Destination schema to the Source schema. ### */ "; listDiff.Add(new SQLScript(header, 0, ScriptAction.None)); if (!isAzure10) { listDiff.Add("USE [" + Name + "]\r\nGO\r\n\r\n", 0, ScriptAction.UseDatabase); listDiff.AddRange(Assemblies.ToSqlDiff(schemas)); listDiff.AddRange(UserTypes.ToSqlDiff(schemas)); } listDiff.AddRange(TablesTypes.ToSqlDiff(schemas)); listDiff.AddRange(Tables.ToSqlDiff(schemas)); listDiff.AddRange(Rules.ToSqlDiff(schemas)); listDiff.AddRange(Schemas.ToSqlDiff(schemas)); listDiff.AddRange(XmlSchemas.ToSqlDiff(schemas)); listDiff.AddRange(Procedures.ToSqlDiff(schemas)); if (!isAzure10) { listDiff.AddRange(CLRProcedures.ToSqlDiff(schemas)); listDiff.AddRange(CLRFunctions.ToSqlDiff(schemas)); listDiff.AddRange(FileGroups.ToSqlDiff(schemas)); } listDiff.AddRange(DDLTriggers.ToSqlDiff(schemas)); listDiff.AddRange(Synonyms.ToSqlDiff(schemas)); listDiff.AddRange(Views.ToSqlDiff(schemas)); listDiff.AddRange(Users.ToSqlDiff(schemas)); listDiff.AddRange(Functions.ToSqlDiff(schemas)); listDiff.AddRange(Roles.ToSqlDiff(schemas)); listDiff.AddRange(PartitionFunctions.ToSqlDiff(schemas)); listDiff.AddRange(PartitionSchemes.ToSqlDiff(schemas)); if (!isAzure10) { listDiff.AddRange(FullText.ToSqlDiff(schemas)); } return(listDiff); }
public override SQLScriptList ToSqlDiff(List <ISchemaBase> schemas) { var isAzure10 = this.Info.Version == DatabaseInfo.VersionTypeEnum.SQLServerAzure10; var listDiff = new SQLScriptList(); listDiff.Add(new SQLScript(String.Format(@"/* Open DBDiff {0} http://opendbiff.codeplex.com/ Script created by {1}\{2} on {3} at {4}. Created on: {5} Source: {6} on {7} Destination: {8} on {9} */ ", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(), Environment.UserDomainName, Environment.UserName, DateTime.Now.ToShortDateString(), DateTime.Now.ToLongTimeString(), Environment.MachineName, SourceInfo != null ? SourceInfo.Database : "Uknown", SourceInfo != null ? SourceInfo.Server : "Uknown", Info != null ? Info.Database : "Uknown", Info != null ? Info.Server : "Uknown", 0), 0, Enums.ScripActionType.None)); if (!isAzure10) { listDiff.Add("USE [" + Name + "]\r\nGO\r\n\r\n", 0, Enums.ScripActionType.UseDatabase); listDiff.AddRange(Assemblies.ToSqlDiff(schemas)); listDiff.AddRange(UserTypes.ToSqlDiff(schemas)); } listDiff.AddRange(TablesTypes.ToSqlDiff(schemas)); listDiff.AddRange(Tables.ToSqlDiff(schemas)); listDiff.AddRange(Rules.ToSqlDiff(schemas)); listDiff.AddRange(Schemas.ToSqlDiff(schemas)); listDiff.AddRange(XmlSchemas.ToSqlDiff(schemas)); listDiff.AddRange(Procedures.ToSqlDiff(schemas)); if (!isAzure10) { listDiff.AddRange(CLRProcedures.ToSqlDiff(schemas)); listDiff.AddRange(CLRFunctions.ToSqlDiff(schemas)); listDiff.AddRange(FileGroups.ToSqlDiff(schemas)); } listDiff.AddRange(DDLTriggers.ToSqlDiff(schemas)); listDiff.AddRange(Synonyms.ToSqlDiff(schemas)); listDiff.AddRange(Views.ToSqlDiff(schemas)); listDiff.AddRange(Users.ToSqlDiff(schemas)); listDiff.AddRange(Functions.ToSqlDiff(schemas)); listDiff.AddRange(Roles.ToSqlDiff(schemas)); listDiff.AddRange(PartitionFunctions.ToSqlDiff(schemas)); listDiff.AddRange(PartitionSchemes.ToSqlDiff(schemas)); if (!isAzure10) { listDiff.AddRange(FullText.ToSqlDiff(schemas)); } return(listDiff); }
public override SQLScriptList ToSqlDiff(List <ISchemaBase> schemas) { var isAzure10 = this.Info.Version == DatabaseInfo.VersionTypeEnum.SQLServerAzure10; var listDiff = new SQLScriptList(); listDiff.Add(new SQLScript(String.Format(@"/* 数据库差异脚本 脚本创建于: {1}\{2} 时间: {3} {4} 创建人:{5} 参考数据库:{6} 地址:{7} 目标数据库:{8} 地址:{9} */ ", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(), Environment.UserDomainName, Environment.MachineName, DateTime.Now.ToShortDateString(), DateTime.Now.ToLongTimeString(), Environment.UserName, SourceInfo != null ? SourceInfo.Database : "Uknown", SourceInfo != null ? SourceInfo.Server : "Uknown", Info != null ? Info.Database : "Uknown", Info != null ? Info.Server : "Uknown", 0), 0, Enums.ScripActionType.None)); if (!isAzure10) { listDiff.Add("USE [" + Name + "]\r\nGO\r\n\r\n", 0, Enums.ScripActionType.UseDatabase); listDiff.AddRange(Assemblies.ToSqlDiff(schemas)); listDiff.AddRange(UserTypes.ToSqlDiff(schemas)); } listDiff.AddRange(TablesTypes.ToSqlDiff(schemas)); listDiff.AddRange(Tables.ToSqlDiff(schemas)); listDiff.AddRange(Rules.ToSqlDiff(schemas)); listDiff.AddRange(Schemas.ToSqlDiff(schemas)); listDiff.AddRange(XmlSchemas.ToSqlDiff(schemas)); listDiff.AddRange(Procedures.ToSqlDiff(schemas)); if (!isAzure10) { listDiff.AddRange(CLRProcedures.ToSqlDiff(schemas)); listDiff.AddRange(CLRFunctions.ToSqlDiff(schemas)); listDiff.AddRange(FileGroups.ToSqlDiff(schemas)); } listDiff.AddRange(DDLTriggers.ToSqlDiff(schemas)); listDiff.AddRange(Synonyms.ToSqlDiff(schemas)); listDiff.AddRange(Views.ToSqlDiff(schemas)); listDiff.AddRange(Users.ToSqlDiff(schemas)); listDiff.AddRange(Functions.ToSqlDiff(schemas)); listDiff.AddRange(Roles.ToSqlDiff(schemas)); listDiff.AddRange(PartitionFunctions.ToSqlDiff(schemas)); listDiff.AddRange(PartitionSchemes.ToSqlDiff(schemas)); if (!isAzure10) { listDiff.AddRange(FullText.ToSqlDiff(schemas)); } return(listDiff); }