namespace FotbalPortal.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class first : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Regions",
                c => new
                    {
                        id = c.Int(nullable: false, identity: true),
                        name = c.String(),
                    })
                .PrimaryKey(t => t.id);
            
            CreateTable(
                "dbo.Countries",
                c => new
                    {
                        id = c.Int(nullable: false, identity: true),
                        name = c.String(),
                        regionID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.id)
                .ForeignKey("dbo.Regions", t => t.regionID, cascadeDelete: true)
                .Index(t => t.regionID);
            
            CreateTable(
                "dbo.Clubs",
                c => new
                    {
                        id = c.Int(nullable: false, identity: true),
                        name = c.String(),
                        countryID = c.Int(nullable: false),
                        yearFounded = c.Int(nullable: false),
                        info = c.String(),
                        email = c.String(),
                        tel = c.String(),
                        address = c.String(),
                        stadiumID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.id)
                .ForeignKey("dbo.Countries", t => t.countryID, cascadeDelete: true)
                .ForeignKey("dbo.Stadia", t => t.stadiumID, cascadeDelete: true)
                .Index(t => t.countryID)
                .Index(t => t.stadiumID);
            
            CreateTable(
                "dbo.Stadia",
                c => new
                    {
                        id = c.Int(nullable: false, identity: true),
                        name = c.String(),
                        address = c.String(),
                        capacity = c.Int(nullable: false),
                        image = c.String(),
                    })
                .PrimaryKey(t => t.id);
            
        }
        
        public override void Down()
        {
            DropIndex("dbo.Clubs", new[] { "stadiumID" });
            DropIndex("dbo.Clubs", new[] { "countryID" });
            DropIndex("dbo.Countries", new[] { "regionID" });
            DropForeignKey("dbo.Clubs", "stadiumID", "dbo.Stadia");
            DropForeignKey("dbo.Clubs", "countryID", "dbo.Countries");
            DropForeignKey("dbo.Countries", "regionID", "dbo.Regions");
            DropTable("dbo.Stadia");
            DropTable("dbo.Clubs");
            DropTable("dbo.Countries");
            DropTable("dbo.Regions");
        }
    }
}
