Пример #1
0
        public void UpdateSchema(IDatabaseAccess db, string tableName, string autoIncrementName, IDictionary <string, int> oldColumns, IDictionary <string, int> changedColumns, IDictionary <string, int> addedColumns)
        {
            CommonDatabaseDetails.FixLongToDoubleUpgrade(this, db, tableName, oldColumns, changedColumns, RANK_INT64, RANK_DOUBLE, RANK_TEXT_32);

            tableName = QuoteName(tableName);

            foreach (var entry in changedColumns)
            {
                db.Exec(String.Format("alter table {0} alter column {1} {2}", tableName, QuoteName(entry.Key), GetSqlTypeFromRank(entry.Value)));
            }

            foreach (var entry in addedColumns)
            {
                db.Exec(String.Format("alter table {0} add {1} {2}", tableName, QuoteName(entry.Key), GetSqlTypeFromRank(entry.Value)));
            }
        }
Пример #2
0
        public void UpdateSchema(IDatabaseAccess db, string tableName, string autoIncrementName, IDictionary <string, int> oldColumns, IDictionary <string, int> changedColumns, IDictionary <string, int> addedColumns)
        {
            var operations = new List <string>();

            CommonDatabaseDetails.FixLongToDoubleUpgrade(this, db, tableName, oldColumns, changedColumns, RANK_INT64, RANK_DOUBLE, RANK_NUMERIC);

            foreach (var entry in changedColumns)
            {
                operations.Add(String.Format("alter {0} type {1} using {0}::{1}", QuoteName(entry.Key), GetSqlTypeFromRank(entry.Value)));
            }

            foreach (var entry in addedColumns)
            {
                operations.Add(String.Format("add {0} {1}", QuoteName(entry.Key), GetSqlTypeFromRank(entry.Value)));
            }

            db.Exec("alter table " + QuoteName(tableName) + " " + String.Join(", ", operations));
        }