Commit 6a0d3024 authored by Marcel Nellesen's avatar Marcel Nellesen
Browse files

Merge branch 'Sprint/2020-06' into 'master'

Sprint/2020-06

See merge request coscine/cs/migrations!7
parents 0bc85c3c d7c5a00e
using FluentMigrator;
using System.Threading;
namespace Coscine.Database.Migration.Migrations
{
//yyyymmddhhmm
[Migration(202003121255)]
public class Migration202003121255ActivatedFeatures : FluentMigrator.Migration
{
public override void Down()
{
Delete.ForeignKey()
.FromTable("ActivatedFeatures").ForeignColumn("ProjectId")
.ToTable("Projects").PrimaryColumn("Id");
Delete.ForeignKey()
.FromTable("ActivatedFeatures").ForeignColumn("FeatureId")
.ToTable("Features").PrimaryColumn("Id");
Delete.Table("ActivatedFeatures");
Delete.Table("Features");
}
public override void Up()
{
Create.Table("Features")
.WithColumn("Id").AsGuid().PrimaryKey().WithDefault(SystemMethods.NewGuid)
.WithColumn("SharepointId").AsString(200).NotNullable()
.WithColumn("DisplaynameEn").AsString(200).NotNullable()
.WithColumn("DisplaynameDe").AsString(200).NotNullable();
Create.Table("ActivatedFeatures")
.WithColumn("Id").AsGuid().PrimaryKey().WithDefault(SystemMethods.NewGuid)
.WithColumn("ProjectId").AsGuid().NotNullable()
.WithColumn("FeatureId").AsGuid().NotNullable();
Create.ForeignKey()
.FromTable("ActivatedFeatures").ForeignColumn("ProjectId")
.ToTable("Projects").PrimaryColumn("Id");
Create.ForeignKey()
.FromTable("ActivatedFeatures").ForeignColumn("FeatureId")
.ToTable("Features").PrimaryColumn("Id");
Insert.IntoTable("Features").Row(new { SharepointId = "MSOZoneCell_WebPartWPQ2", DisplaynameEN = "Discussion Board", DisplaynameDe = "Discussion Board" });
Insert.IntoTable("Features").Row(new { SharepointId = "MSOZoneCell_WebPartWPQ3", DisplaynameEN = "Documents", DisplaynameDe = "Dokumente" });
Insert.IntoTable("Features").Row(new { SharepointId = "MSOZoneCell_WebPartWPQ4", DisplaynameEN = "Announcement Board", DisplaynameDe = "Announcement Board" });
Execute.EmbeddedScript("Migration202003121255ActivatedFeatures_up.sql");
}
}
}
INSERT INTO [Coscine].[dbo].[ActivatedFeatures] (ProjectId, FeatureId)
SELECT [Coscine].[dbo].[Projects].[Id],
[Coscine].[dbo].[Features].[Id]
FROM [Coscine].[dbo].[Projects]
CROSS JOIN [Coscine].[dbo].[Features]
\ No newline at end of file
......@@ -165,6 +165,7 @@
<Compile Include="Migrations\Migration202001270800ResourceFlags.cs" />
<Compile Include="Migrations\Migration202002041409ProjectDeletedColumn.cs" />
<Compile Include="Migrations\Migration202002101300MoreLicenses.cs" />
<Compile Include="Migrations\Migration202003121255ActivatedFeatures.cs" />
<Compile Include="Migrations\Migration202003192117ORCiDEmailAddress.cs" />
<Compile Include="Migrator.cs" />
<Compile Include="Program.cs" />
......@@ -177,7 +178,9 @@
<EmbeddedResource Include="Assets\Institutes.csv" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<EmbeddedResource Include="Migrations\Migration202003121255ActivatedFeatures_up.sql" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\FluentMigrator.Runner.SqlServerCe.3.1.3\build\netstandard2.0\FluentMigrator.Runner.SqlServerCe.targets" Condition="Exists('..\packages\FluentMigrator.Runner.SqlServerCe.3.1.3\build\netstandard2.0\FluentMigrator.Runner.SqlServerCe.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment