C# Class Insight.Database.Schema.SchemaInstaller

Show file Open project: jonwagner/Insight.Database.Schema Class Usage Examples

Public Methods

Method Description
CreateDatabase ( string connectionString ) : bool

Create a database on the specified connection if it does not exist.

DatabaseExists ( string connectionString ) : bool

Check to see if the database exists

Diff ( string schemaGroup, SchemaObjectCollection schema ) : bool

Determine if the given schema has differences with the current schema.

DropDatabase ( string connectionString ) : bool

Drop a database if it exists.

SchemaInstaller ( DbConnection connection ) : System

Initialize the SchemaInstaller to work with a given SqlConnection.

ScriptChanges ( string schemaGroup, SchemaObjectCollection schema ) : string

Script the changes that would be applied to the database.

Uninstall ( string schemaGroup ) : void

Uninstall a schema group from the database.

This is a transactional operation

Private Methods

Method Description
AddObjects ( InstallContext context ) : void

Add all of the objects that need to be added.

CompareByInstallOrder ( Insight.Database.Schema.SchemaObject o1, Insight.Database.Schema.SchemaObject o2 ) : int

Compares two schema objects to determine the appropriate installation order.

CompareByInstallOrder ( Insight.Database.Schema.SchemaRegistryEntry e1, Insight.Database.Schema.SchemaRegistryEntry e2 ) : int

Compares two registry entry objects to determine the appropriate installation order.

DropObjects ( IEnumerable dropObjects ) : void

Drop objects that need to be dropped.

GetColumnDefinition ( dynamic column ) : string
GetColumnsForTable ( string tableName ) : IEnumerable

Get the columns for a table.

GetDefaultDefinition ( dynamic def ) : string

Output the definition of a default.

GetMasterConnectionString ( string connectionString ) : string

Gets the connection string needed to connect to the master database. This is used when creating/dropping databases.

Install ( string schemaGroup, SchemaObjectCollection schema ) : void
OpenMasterConnection ( string connectionString ) : SqlConnection

Opens a connection needed to connect to the master database. This is used when creating/dropping databases.

ScriptColumnsAndConstraints ( InstallContext context, Insight.Database.Schema.SchemaObject schemaObject, string oldTableName, string newTableName ) : void
ScriptForeignKeys ( InstallContext context, Insight.Database.Schema.SchemaObject schemaObject ) : void
ScriptIndexes ( InstallContext context, Insight.Database.Schema.SchemaObject schemaObject, string columnName = null ) : void
ScriptPermissions ( InstallContext context, Insight.Database.Schema.SchemaObject schemaObject ) : void

Script the permissions on an object and save the script to add the permissions back later

ScriptStandardDependencies ( InstallContext context, Insight.Database.Schema.SchemaObject schemaObject ) : void

Script the standard dependencies such as stored procs and triggers.

ScriptTableUpdate ( InstallContext context, Insight.Database.Schema.SchemaObject schemaObject ) : void

Script the update of a table.

ScriptUpdate ( InstallContext context, Insight.Database.Schema.SchemaObject schemaObject ) : void

Schedule an update by adding the appropriate delete, update and add records

ScriptXmlIndexes ( InstallContext context, Insight.Database.Schema.SchemaObject schemaObject ) : void
VerifyObjects ( List schemaObjects ) : void

Verify that all of the objects that are supposed to be there really are...

Method Details

CreateDatabase() public static method

Create a database on the specified connection if it does not exist.
If the database name is invalid.
public static CreateDatabase ( string connectionString ) : bool
connectionString string
return bool

DatabaseExists() public static method

Check to see if the database exists
public static DatabaseExists ( string connectionString ) : bool
connectionString string The connection string for the database to connect to.
return bool

Diff() public method

Determine if the given schema has differences with the current schema.
public Diff ( string schemaGroup, SchemaObjectCollection schema ) : bool
schemaGroup string The schema group to compare.
schema SchemaObjectCollection The schema to compare with.
return bool

DropDatabase() public static method

Drop a database if it exists.
If the database name is invalid or cannot be dropped.
public static DropDatabase ( string connectionString ) : bool
connectionString string
return bool

SchemaInstaller() public method

Initialize the SchemaInstaller to work with a given SqlConnection.
public SchemaInstaller ( DbConnection connection ) : System
connection System.Data.Common.DbConnection The SqlConnection to work with.
return System

ScriptChanges() public method

Script the changes that would be applied to the database.
public ScriptChanges ( string schemaGroup, SchemaObjectCollection schema ) : string
schemaGroup string The name of the schemaGroup.
schema SchemaObjectCollection The schema to install.
return string

Uninstall() public method

Uninstall a schema group from the database.
This is a transactional operation
If schemaGroup is null If any object fails to uninstall
public Uninstall ( string schemaGroup ) : void
schemaGroup string The group to uninstall
return void