Exemplo n.º 1
0
 public void Setup()
 {
     t = new Table("items");
     t.AddColumn("id", "integer", true, true, true);
     t.AddColumn("name");
     t.AddColumn("description");
     t.AddColumn("price", "double");
 }
Exemplo n.º 2
0
        public void Setup()
        {
            t = new Table("users");
            t.AddColumn("id", "integer", true, true, true);
            t.AddColumn("name");
            t.AddColumn("password");

            f = new MySQLMigrationFormatter("");
        }
Exemplo n.º 3
0
 public string GetCreateTable(Table table)
 {
     string cols = "";
     int i = 0;
     foreach (var c in table.Columns) {
         string notNull = c.NotNull ? " not null" : "";
         string primaryKey = c.PrimaryKey ? " primary key" : "";
         cols += string.Format("  {0} {1}{2}{3}", c.Name, c.Type, notNull, primaryKey);
         cols += i++ < table.Columns.Count - 1 ? "," : "";
         cols += Environment.NewLine;
     }
     return string.Format(@"create table {0}({1});", table.Name, cols);
 }
Exemplo n.º 4
0
 public string GetCreateTable(Table table)
 {
     string cols = "";
     int i = 0;
     foreach (var c in table.Columns) {
         cols += c.Name + " " + c.Type;
         cols += c.PrimaryKey ? " primary key" : "";
         cols += c.NotNull ? " not null" : "";
         cols += c.AutoIncrement ? " identity" : "";
         cols += i++ < table.Columns.Count - 1 ? ", " : "";
     }
     return string.Format("create table {0}({1})", table.Name, cols);
 }
Exemplo n.º 5
0
 public TableEventArgs(Table table, ICollection<KeyValuePair<string, object>> values, ICollection<KeyValuePair<string, object>> @where)
 {
     this.Table = table;
     this.Values = values;
     this.Where = @where;
 }
Exemplo n.º 6
0
 public TableEventArgs(Table table, ICollection<KeyValuePair<string, object>> values)
 {
     this.Table = table;
     this.Values = values;
 }
Exemplo n.º 7
0
 public TableEventArgs(Table table)
 {
     this.Table = table;
 }
Exemplo n.º 8
0
 public void CreateTable(Table table)
 {
     ExecuteNonQuery(f.GetCreateTable(table));
 }
Exemplo n.º 9
0
        public void RemoveColumn(string tableName, params string[] columns)
        {
            string cols = "";
            int i = 1;
            foreach (var c in columns) {
                cols += c;
                if (i++ < columns.Length) {
                    cols += ", ";
                }
            }
            OnMigrating(new MigrationEventArgs(string.Format("Removing {0} from {1}...", cols, tableName)));

            var t = new Table(tableName);
            foreach (var c in columns) {
                t.AddColumn(c);
            }
            OnColumnRemove(new TableEventArgs(t));
        }
Exemplo n.º 10
0
 protected void CreateTable(Table table)
 {
     OnMigrating(new MigrationEventArgs(string.Format("Creating table {0}...", table.Name)));
     OnTableCreate(new TableEventArgs(table));
 }