Method BuildSchema
- Namespace
- YndigoBlue.Velocity.Engine
- Assembly
- YndigoBlue.Velocity.dll
BuildSchema(Schema, bool, bool)
Creates or recreates a complete schema in the database including all tables, views, constraints, and indexes.
public void BuildSchema(Schema schema, bool overwrite = false, bool ignoreWarnings = false)
Parameters
schemaSchemaA Schema object defining the complete schema structure to create.
overwriteboolIf true, drops and recreates existing tables and views; 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 schema from file
var schema = m.ReadSchemaFromFile("schema.xml", ConfigType.Xml);
// Build the entire schema
m.BuildSchema(schema, overwrite: true);
Console.WriteLine($"Built schema '{schema.Name}' with {schema.Tables.Count} tables");
}
Exceptions
- DbException
Thrown when a database error occurs.