Source

TrafficLight / src / Core / Data / Migrations / ProjectsTable.cs

Full commit
using System;
using System.Data;
using Migrator.Framework;

namespace RossCode.TrafficLight.Core.Data.Migrations
{
    [Migration(200907192130)]
    public class ProjectsTable : Migration
    {
        public override void Up()
        {
            Database.AddTable("Projects",
                              new Column("Id", DbType.Int32, ColumnProperty.PrimaryKey),
                              new Column("Name", DbType.String, 50, ColumnProperty.NotNull),
                              new Column("Url", DbType.String, 1000, ColumnProperty.NotNull));
        }

        public override void Down()
        {
            Database.RemoveTable("Projects");
        }
    }

    [Migration(201209192313)]
    public class ProjectsAddCredentials : Migration
    {
        public override void Up()
        {
            Database.AddColumn("Projects", "Username", DbType.String, 50, ColumnProperty.Null);
            Database.AddColumn("Projects", "Password", DbType.String, 50, ColumnProperty.Null);
        }

        public override void Down()
        {
            Database.RemoveColumn("Projects", "Username");
            Database.RemoveColumn("Projects", "Password");
        }
    }

    [Migration(201210172338)]
    public class ProjectsAddServerType : Migration
    {
        public override void Up()
        {
            Database.AddColumn("Projects", "ServerType", DbType.Int32, ColumnProperty.Null);
            Database.ExecuteNonQuery("update Projects set ServerType = 1");
        }

        public override void Down()
        {
            Database.RemoveColumn("Projects", "ServerType");
        }
    }

    [Migration(201210252139)]
    public class ProjectsTable_201210252139 : Migration
    {
        public override void Up()
        {
            if (Convert.ToInt32(Database.ExecuteScalar("select count(Id) from Projects")) == 0)
            {
                Database.ExecuteNonQuery("insert into Projects (Name, Url, Username, Password, ServerType) values ('Traffic Light :: Traffic Light Trunk', 'http://teamcity.codebetter.com/guestAuth/app/rest/cctray/projects.xml', '', '', 1)");
            }
        }

        public override void Down()
        {

        }
    }
}