protected void ScriptSproc(IProcedure sproc, IScriptWriter writer) { Throw.If(sproc, "sproc").IsNull(); Throw.If(writer, "writer").IsNull(); string name = DbObjectName.CreateDbObjectName(sproc); string msg = string.Format("Scripting stored procedure {0}", name); messageManager.OnScriptMessage(msg); SqlScript script = scriptBuilder.Create(sproc); writer.WriteSprocScript(name, script.ToScript()); }
protected void ScriptView(IView view, IScriptWriter writer) { Throw.If(view, "view").IsNull(); Throw.If(writer, "writer").IsNull(); string name = DbObjectName.CreateDbObjectName(view); string msg = string.Format("Scripting view {0}", name); messageManager.OnScriptMessage(msg); SqlScript script = scriptBuilder.Create(view); writer.WriteViewScript(name, script.ToScript()); }
protected void ScriptTableSchema(ITable table, IScriptWriter writer) { Throw.If(table, "table").IsNull(); Throw.If(writer, "writer").IsNull(); string tableName = DbObjectName.CreateDbObjectName(table); string msg = string.Format("Scripting {0} table schema", tableName); messageManager.OnScriptMessage(msg); SqlScript script = scriptBuilder.Create(table); writer.WriteTableScript(tableName, script.ToScript()); }
/// <summary> /// Generates table data inserts and updates to sync two tables in /// different databases. /// </summary> /// <param name="migrator">The data migrator instance.</param> /// <param name="source">The source table to script all data from.</param> /// <param name="writer">The script writer strategy.</param> protected virtual void ScriptTableData(IDataMigrator migrator, ITable source, IScriptWriter writer) { Throw.If(source, "source").IsNull(); Throw.If(writer, "writer").IsNull(); string name = DbObjectName.CreateDbObjectName(source); messageManager.OnScriptMessage( string.Format("Starting table data scripting on table {0}.", name)); script = new SqlScript(); script = migrator.ScriptAllData(source, script); writer.WriteTableDataScript(name, script.ToScript()); messageManager.OnScriptMessage( string.Format("Finished table data scripting on table {0}.", name)); }
protected virtual void ScriptTableDataDifferences(ITable sourceTable, ITable targetTable, IScriptWriter writer) { Throw.If(sourceTable, "sourceTable").IsNull(); Throw.If(targetTable, "targetTable").IsNull(); Throw.If(writer, "writer").IsNull(); string name = DbObjectName.CreateDbObjectName(sourceTable); messageManager.OnScriptMessage( string.Format("Starting table data difference scripting on table {0}.", name)); script = new SqlScript(); DifferentialDataMigrator migrator = new DifferentialDataMigrator(); script = migrator.ScriptDataDifferences(sourceTable, targetTable, script); writer.WriteTableDataScript(name, script.ToScript()); messageManager.OnScriptMessage( string.Format("Finished table data difference scripting on table {0}.", name)); }
protected void ScriptTableIndexes(ITable table, IScriptWriter writer) { Throw.If(table, "table").IsNull(); Throw.If(writer, "writer").IsNull(); string tableName = DbObjectName.CreateDbObjectName(table); string msg = string.Format("Scripting {0} indexes", tableName); messageManager.OnScriptMessage(msg); SqlScript script = new SqlScript(); foreach (IIndex index in table.Indexes) { msg = string.Format("Scripting index {0}", index.Name); messageManager.OnScriptMessage(msg); script += scriptBuilder.Create(index); } writer.WriteIndexScript(tableName, script.ToScript()); }