You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.4 KiB

using OpenDBDiff.Abstractions.Schema;
using OpenDBDiff.Abstractions.Schema.Model;
using System.Text;
namespace OpenDBDiff.SqlServer.Schema.Model
{
public class Schema : SQLServerSchemaBase
{
public Schema(Database parent)
: base(parent, ObjectType.Schema)
{
}
public override string ToSql()
{
StringBuilder sql = new StringBuilder();
sql.Append("CREATE SCHEMA ");
sql.Append("[" + this.Name + "] AUTHORIZATION [" + Owner + "]");
sql.Append("\r\nGO\r\n");
return sql.ToString();
}
public override string ToSqlAdd()
{
return ToSql();
}
public override string ToSqlDrop()
{
return "DROP SCHEMA [" + Name + "]\r\nGO\r\n";
}
/// <summary>
/// Devuelve el schema de diferencias del Schema en formato SQL.
/// </summary>
public override SQLScriptList ToSqlDiff(System.Collections.Generic.ICollection<ISchemaBase> schemas)
{
SQLScriptList listDiff = new SQLScriptList();
if (this.Status == ObjectStatus.Drop)
{
listDiff.Add(ToSqlDrop(), 0, ScriptAction.DropSchema);
}
if (this.Status == ObjectStatus.Create)
{
listDiff.Add(ToSql(), 0, ScriptAction.AddSchema);
}
return listDiff;
}
}
}