OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
Public Member Functions | Protected Member Functions | Protected Attributes | Properties | List of all members
OpenSim.Data.Migration Class Reference

More...

Inheritance diagram for OpenSim.Data.Migration:
Inheritance graph
[legend]

Public Member Functions

 Migration ()
 Have the parameterless constructor just so we can specify it as a generic parameter with the new() constraint. Currently this is only used in the tests. A Migration instance created this way must be then initialized with Initialize(). Regular creation should be through the parameterized constructors. More...
 
 Migration (DbConnection conn, Assembly assem, string subtype, string type)
 
 Migration (DbConnection conn, Assembly assem, string type)
 
void Initialize (DbConnection conn, Assembly assem, string type, string subtype)
 Must be called after creating with the parameterless constructor. NOTE that the Migration class now doesn't access database in any way during initialization. Specifically, it won't check if the [migrations] table exists. Such checks are done later: automatically on Update(), or you can explicitly call InitMigrationsTable(). More...
 
void InitMigrationsTable ()
 
void Update ()
 

Protected Member Functions

virtual void ExecuteScript (DbConnection conn, string[] script)
 Executes a script, possibly in a database-specific way. It can be redefined for a specific DBMS, if necessary. Specifically, to avoid problems with proc definitions in MySQL, we must use MySqlScript class instead of just DbCommand. We don't want to bring MySQL references here, so instead define a MySQLMigration class in OpenSim.Data.MySQL More...
 
void ExecuteScript (DbConnection conn, string sql)
 
void ExecuteScript (string sql)
 
void ExecuteScript (string[] script)
 
virtual int FindVersion (DbConnection conn, string type)
 

Protected Attributes

string _type
 
DbConnection _conn
 
Assembly _assem
 

Properties

int Version [get, set]
 

Detailed Description

The Migration theory is based on the ruby on rails concept. Each database driver is going to be allowed to have files in Resources that specify the database migrations. They will be of the form:

001_Users.sql 002_Users.sql 003_Users.sql 001_Prims.sql 002_Prims.sql ...etc...

When a database driver starts up, it specifies a resource that needs to be brought up to the current revision. For instance:

Migration um = new Migration(DbConnection, Assembly, "Users"); um.Update();

This works out which version Users is at, and applies all the revisions past it to it. If there is no users table, all revisions are applied in order. Consider each future migration to be an incremental roll forward of the tables in question.

Assembly must be specifically passed in because otherwise you get the assembly that Migration.cs is part of, and what you really want is the assembly of your database class.

Definition at line 70 of file Migration.cs.

Constructor & Destructor Documentation

OpenSim.Data.Migration.Migration ( )
inline

Have the parameterless constructor just so we can specify it as a generic parameter with the new() constraint. Currently this is only used in the tests. A Migration instance created this way must be then initialized with Initialize(). Regular creation should be through the parameterized constructors.

Definition at line 85 of file Migration.cs.

OpenSim.Data.Migration.Migration ( DbConnection  conn,
Assembly  assem,
string  subtype,
string  type 
)
inline

Definition at line 89 of file Migration.cs.

OpenSim.Data.Migration.Migration ( DbConnection  conn,
Assembly  assem,
string  type 
)
inline

Definition at line 94 of file Migration.cs.

Member Function Documentation

virtual void OpenSim.Data.Migration.ExecuteScript ( DbConnection  conn,
string[]  script 
)
inlineprotectedvirtual

Executes a script, possibly in a database-specific way. It can be redefined for a specific DBMS, if necessary. Specifically, to avoid problems with proc definitions in MySQL, we must use MySqlScript class instead of just DbCommand. We don't want to bring MySQL references here, so instead define a MySQLMigration class in OpenSim.Data.MySQL

Parameters
conn
scriptArray of strings, one-per-batch (often just one)

Reimplemented in OpenSim.Data.PGSQL.PGSQLMigration, and OpenSim.Data.MySQL.MySqlMigration.

Definition at line 140 of file Migration.cs.

void OpenSim.Data.Migration.ExecuteScript ( DbConnection  conn,
string  sql 
)
inlineprotected

Definition at line 160 of file Migration.cs.

void OpenSim.Data.Migration.ExecuteScript ( string  sql)
inlineprotected

Definition at line 165 of file Migration.cs.

void OpenSim.Data.Migration.ExecuteScript ( string[]  script)
inlineprotected

Definition at line 170 of file Migration.cs.

virtual int OpenSim.Data.Migration.FindVersion ( DbConnection  conn,
string  type 
)
inlineprotectedvirtual

Reimplemented in OpenSim.Data.PGSQL.PGSQLMigration.

Definition at line 238 of file Migration.cs.

void OpenSim.Data.Migration.Initialize ( DbConnection  conn,
Assembly  assem,
string  type,
string  subtype 
)
inline

Must be called after creating with the parameterless constructor. NOTE that the Migration class now doesn't access database in any way during initialization. Specifically, it won't check if the [migrations] table exists. Such checks are done later: automatically on Update(), or you can explicitly call InitMigrationsTable().

Parameters
conn
assem
subtype
type

Definition at line 108 of file Migration.cs.

void OpenSim.Data.Migration.InitMigrationsTable ( )
inline

Definition at line 118 of file Migration.cs.

void OpenSim.Data.Migration.Update ( )
inline

Definition at line 175 of file Migration.cs.

Member Data Documentation

Assembly OpenSim.Data.Migration._assem
protected

Definition at line 76 of file Migration.cs.

DbConnection OpenSim.Data.Migration._conn
protected

Definition at line 75 of file Migration.cs.

string OpenSim.Data.Migration._type
protected

Definition at line 74 of file Migration.cs.

Property Documentation

int OpenSim.Data.Migration.Version
getset

Definition at line 224 of file Migration.cs.


The documentation for this class was generated from the following file: