Method BuildDatabase
- Namespace
- YndigoBlue.Velocity.Engine
- Assembly
- YndigoBlue.Velocity.dll
BuildDatabase(Database, bool, bool)
Creates or recreates a complete database with multiple schemas, including all tables, views, constraints, and indexes.
public void BuildDatabase(Database database, bool overwrite = false, bool ignoreWarnings = false)
Parameters
databaseDatabaseA Database object containing multiple schemas to create.
overwriteboolIf true, drops and recreates existing schemas and their objects; if false, throws an error if objects exist.
ignoreWarningsboolIf true, ignores warnings for operations not supported by the database.
Examples
var conn = new PostgreSqlDatasourceConnection
{
Hostname = "localhost",
Port = 5432,
Username = "postgres",
Password = "password",
Database = "mydb"
};
using (var m = new Manager(conn))
{
// Read database definition with multiple schemas
var database = m.ReadDatabaseFromFile("database.json", ConfigType.Json);
// Build all schemas and tables
m.BuildDatabase(database, overwrite: true);
Console.WriteLine($"Built {database.Schemas.Count} schemas");
}
Remarks
WARNING: Multi-schema database operations are not available in the Community Edition of Velocity. They require the Full Edition.
Exceptions
- DbException
Thrown when a database error occurs.