예제 #1
0
 private object CreateForeignKeyMigration(Table table, ForeignKey fk)
 {
     var up = new
                  {
                      foreign_key = new
                                        {
                                            name = fk.Name,
                                            from = new
                                                       {
                                                           table = table.Name,
                                                           columns = fk.Columns.Select(c => c.ColumnName).ToArray()
                                                       },
                                            to = new
                                                     {
                                                         table = fk.ReferencedObjectName,
                                                         columns = fk.Columns.Select(c => c.ReferencedColumnName).ToArray()
                                                     }
                                        }
                  };
     var down = new
                    {
                        drop_constraint= new
                                             {
                                                 table = table.Name,
                                                 name = fk.Name
                                             }
                    };
     var migration = new { up, down };
     return migration;
 }
예제 #2
0
 private void DeriveTableMigration(int nr, Table table)
 {
     string name = string.Format("create_{0}", table.Name);
     var migration = CreateTableMigration(table);
     WriteMigration(nr, name, migration);
 }
예제 #3
0
 private static object CreateTableMigration(Table table)
 {
     dynamic up = new
                      {
                          create_table = new
                                             {
                                                 name = table.Name,
                                                 timestamps = table.UseTimestamps,
                                                 columns = (from col in table.NonTimestampColumns
                                                            select CreateColumnDefinition(col)).ToArray()
                                             }
                      };
     dynamic down = new
                        {
                            drop_table= table.Name
                        };
     var migration = new {up, down };
     return migration;
 }