namespace TP02Photo_sharing.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class InitialCreate : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Comments",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Subject = c.String(),
                        Body = c.String(),
                        Owner_ID = c.Int(),
                        photo_ID = c.Int(),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Users", t => t.Owner_ID)
                .ForeignKey("dbo.Photos", t => t.photo_ID)
                .Index(t => t.Owner_ID)
                .Index(t => t.photo_ID);
            
            CreateTable(
                "dbo.Users",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Nom = c.String(),
                        Pren = c.String(),
                        DateNais = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.ID);
            
            CreateTable(
                "dbo.Photos",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Title = c.String(),
                        PhotoFile = c.Byte(nullable: false),
                        Description = c.String(),
                        CreatedDate = c.DateTime(nullable: false),
                        Owner_ID = c.Int(),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Users", t => t.Owner_ID)
                .Index(t => t.Owner_ID);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.Photos", "Owner_ID", "dbo.Users");
            DropForeignKey("dbo.Comments", "photo_ID", "dbo.Photos");
            DropForeignKey("dbo.Comments", "Owner_ID", "dbo.Users");
            DropIndex("dbo.Photos", new[] { "Owner_ID" });
            DropIndex("dbo.Comments", new[] { "photo_ID" });
            DropIndex("dbo.Comments", new[] { "Owner_ID" });
            DropTable("dbo.Photos");
            DropTable("dbo.Users");
            DropTable("dbo.Comments");
        }
    }
}
