protected void CheckTable()
        {
            //Console.WriteLine ("In {0} checking for table {1}", this, TableName);
            var schema = Connection.GetSchema(TableName);

            if (schema.Count > 0)
            {
                foreach (var column in columns)
                {
                    if (!schema.ContainsKey(column.Name.ToLower()))
                    {
                        AddColumnToTable(column.Schema);
                    }
                    if (column.Index != null && !Connection.IndexExists(column.Index))
                    {
                        Connection.Execute(string.Format(
                                               "CREATE INDEX {0} ON {1}({2})",
                                               column.Index, TableName, column.Name)
                                           );
                    }
                }
            }
            else
            {
                CreateTable();
            }
        }
Example #2
0
        protected void CheckTable()
        {
            //Console.WriteLine ("In {0} checking for table {1}", this, TableName);
            IDictionary <string, string> schema = connection.GetSchema(TableName);

            if (schema.Count > 0)
            {
                foreach (DatabaseColumn column in columns)
                {
                    if (!schema.ContainsKey(column.Name))
                    {
                        AddColumnToTable(column.Schema);
                    }
                    if (column.Index != null && !connection.IndexExists(column.Index))
                    {
                        connection.Execute(String.Format(
                                               "CREATE INDEX {0} ON {1}({2})",
                                               column.Index, TableName, column.Name)
                                           );
                    }
                }
            }
            else
            {
                CreateTable();
            }
        }