diff --git a/src/Migrator/Migrations/Migration202003121255ActivatedFeatures.cs b/src/Migrator/Migrations/Migration202003121255ActivatedFeatures.cs new file mode 100644 index 0000000000000000000000000000000000000000..be829a3edee0a1792696cca7f4e3343a7d9034bd --- /dev/null +++ b/src/Migrator/Migrations/Migration202003121255ActivatedFeatures.cs @@ -0,0 +1,53 @@ +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"); + } + } +} diff --git a/src/Migrator/Migrations/Migration202003121255ActivatedFeatures_up.sql b/src/Migrator/Migrations/Migration202003121255ActivatedFeatures_up.sql new file mode 100644 index 0000000000000000000000000000000000000000..ea1c9a464380518ea2d964f7b3ae412559337ed0 --- /dev/null +++ b/src/Migrator/Migrations/Migration202003121255ActivatedFeatures_up.sql @@ -0,0 +1,6 @@ +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 diff --git a/src/Migrator/Migrator.csproj b/src/Migrator/Migrator.csproj index 024ce1166002e9a57d89bf0ff7960ba372e581a0..39ca78e7bec27b0c296fdba2fcdb2345f87e9054 100644 --- a/src/Migrator/Migrator.csproj +++ b/src/Migrator/Migrator.csproj @@ -165,6 +165,7 @@ + @@ -176,7 +177,9 @@ - + + +