public virtual void Can_add_foreign_key_composite_to_table() { DataClient.AddTable("Something", Column.Int32("id"), Column.Int32("id_2"), Column.String("name") ); DataClient.Add.PrimaryKey("Something_PK").OnColumns("id", "id_2").OfTable("Something"); DataClient.AddTable("Anotherthing", Column.Int32("id").AsPrimaryKey(), Column.Int32("id_Something"), Column.Int32("id_2_Something") ); DataClient.AddForeignKey("fk_Another_Some", "Anotherthing", new string[] { "id_Something", "id_2_Something" }, "Something", new string[] { "id", "id_2" }, OnDelete.Cascade); DataClient.RemoveForeignKey("fk_Another_Some", "Anotherthing"); DataClient.AddForeignKey("fk_Another_Some", "Anotherthing", new string[] { "id_Something", "id_2_Something" }, "Something", new string[] { "id", "id_2" }, OnDelete.NoAction); DataClient.RemoveForeignKey("fk_Another_Some", "Anotherthing"); DataClient.AddForeignKey("fk_Another_Some", "Anotherthing", new string[] { "id_Something", "id_2_Something" }, "Something", new string[] { "id", "id_2" }, OnDelete.SetNull); DataClient.RemoveForeignKey("fk_Another_Some", "Anotherthing"); DropTable("Anotherthing"); DropTable("Something"); }
public virtual void Can_remove_foreign_key_from_table() { CreateTableFoo(); CreateTableBar(); DataClient.AddForeignKey("fk_foo_bar1", "bar", "id_foo1", "foo", "id", OnDelete.Cascade); DataClient.RemoveForeignKey("fk_foo_bar1", "bar"); }
public virtual void Can_add_foreign_key_to_table() { CreateTableFoo(); CreateTableBar(); DataClient.AddTable("foobar", Column.Int32("id").AsPrimaryKey(), Column.Int32("id_bar") ); DataClient.AddForeignKey("fk_foo_bar1", "bar", "id_foo1", "foo", "id", OnDelete.Cascade); DataClient.AddForeignKey("fk_foo_bar2", "bar", "id_foo2", "foo", "id", OnDelete.NoAction); DataClient.AddForeignKey("fk_foobar_bar", "foobar", "id_bar", "bar", "id", OnDelete.SetNull); }
protected override void ExecuteInternal() { DataClient.AddForeignKey(ForeignKeyName, TableNames[0], Column, ReferencingTable, ReferencingColumnName, OnDelete); }