Table of Contents

Method GetSqlBuildDatabase

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

GetSqlBuildDatabase(Database, bool, bool)

Generates the SQL script that would be used to build a database without executing it.

public string GetSqlBuildDatabase(Database database, bool overwrite = true, bool ignoreWarnings = false)

Parameters

database Database

The Database to generate SQL for.

overwrite bool

If true, includes DROP statements before CREATE statements.

ignoreWarnings bool

If true, ignores warnings for unsupported operations.

Returns

string

A string containing the complete SQL script to build all schemas in the database.

Examples

using (var m = new Manager(conn))
{
    var database = m.ReadDatabaseFromFile("database.json", ConfigType.Json);

    // Generate SQL for all schemas
    string sql = m.GetSqlBuildDatabase(database, overwrite: true);

    // Review or save the script
    File.WriteAllText("database_create.sql", sql);
    Console.WriteLine($"Generated SQL for {database.Schemas.Count} schemas");
}

Exceptions

DbException

Thrown when a database error occurs.