Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sitereactor/5742776 to your computer and use it in GitHub Desktop.
Save sitereactor/5742776 to your computer and use it in GitHub Desktop.
Example of a database migration used in the Core of Umbraco to create a new table with two columns for the upgrade - as well as deleting the same table and columns as part of the downgrade.
using Umbraco.Core.Configuration;
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix
{
[Migration("6.0.0", 4, GlobalSettings.UmbracoMigrationName)]
public class NewCmsContentType2ContentTypeTable : MigrationBase
{
public override void Up()
{
Create.Table("cmsContentType2ContentType")
.WithColumn("parentContentTypeId").AsInt16().NotNullable()
.WithColumn("childContentTypeId").AsInt16().NotNullable();
Create.PrimaryKey("PK_cmsContentType2ContentType")
.OnTable("cmsContentType2ContentType")
.Columns(new[] {"parentContentTypeId", "childContentTypeId"});
}
public override void Down()
{
Delete.PrimaryKey("PK_cmsContentType2ContentType").FromTable("cmsContentType2ContentType");
Delete.Table("cmsContentType2ContentType");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment