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
databaseDatabaseThe Database to generate SQL for.
overwriteboolIf true, includes DROP statements before CREATE statements.
ignoreWarningsboolIf 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.