Table of Contents

Method UpdateSchema

Namespace
YndigoBlue.Velocity.Engine
Assembly
YndigoBlue.Velocity.dll

UpdateSchema(Schema, bool)

Updates an existing schema to match the provided schema definition by adding, modifying, or removing objects.

public void UpdateSchema(Schema schema, bool ignoreWarnings = false)

Parameters

schema Schema

A Schema object containing the desired schema state.

ignoreWarnings bool

If true, ignores warnings for operations not supported by the database.

Examples

var conn = new SqlServerDatasourceConnection
{
    Hostname = "localhost",
    Port = 1433,
    Username = "sa",
    Password = "Password123",
    Database = "mydb"
};

using (var m = new Manager(conn))
{
    // Load existing schema from database
    var schema = m.LoadSchema("app");

    // Add a new table
    var newTable = new Table(schema, "products");
    newTable.AddColumn(new Column("id", DataType.Integer) { PrimaryKey = true });
    schema.AddTable(newTable);

    // Update the database to match
    m.UpdateSchema(schema);
}

Remarks

WARNING: The UpdateSchema method is not available in the Community Edition of Velocity. It requires the Full Edition.

Exceptions

DbException

Thrown when a database error occurs.