Created
June 9, 2013 08:16
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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