31 using System.Data.Common;
32 using System.Reflection;
34 namespace OpenSim.Data.PGSQL
39 : base(conn, assem, type)
43 public PGSQLMigration(NpgsqlConnection conn, Assembly assem,
string subtype,
string type)
44 : base(conn, assem, subtype, type)
48 protected override int FindVersion(DbConnection conn,
string type)
51 NpgsqlConnection lcConn = (NpgsqlConnection)conn;
53 using (NpgsqlCommand cmd = lcConn.CreateCommand())
57 cmd.CommandText =
"select version from migrations where name = '" + type +
"' " +
58 " order by version desc limit 1";
59 using (NpgsqlDataReader reader = cmd.ExecuteReader())
63 version = Convert.ToInt32(reader[
"version"]);
77 protected override void ExecuteScript(DbConnection conn,
string[] script)
79 if (!(conn is NpgsqlConnection))
81 base.ExecuteScript(conn, script);
85 foreach (
string sql
in script)
89 using (NpgsqlCommand cmd =
new NpgsqlCommand(sql, (NpgsqlConnection)conn))
91 cmd.ExecuteNonQuery();
96 throw new Exception(sql);
PGSQLMigration(NpgsqlConnection conn, Assembly assem, string subtype, string type)
PGSQLMigration(NpgsqlConnection conn, Assembly assem, string type)
override int FindVersion(DbConnection conn, string type)
override void ExecuteScript(DbConnection conn, string[] script)
Executes a script, possibly in a database-specific way. It can be redefined for a specific DBMS...