Commit 37db34e2 authored by Marcel Nellesen's avatar Marcel Nellesen
Browse files

Merge branch 'Product/702-createUserProfile' into 'Sprint/2020-10'

Product/702-createUserProfile

See merge request coscine/cs/migrations!19
parents 0cec191b 97b9a4ea
using FluentMigrator;
namespace Coscine.Database.Migration.Migrations
{
//yyyymmddhhmm
[Migration(202005151300)]
public class Migration202005151300ExtendUser : FluentMigrator.Migration
{
public override void Down()
{
#region Foreign Keys
Delete.ForeignKey()
.FromTable("Users").ForeignColumn("TitleId")
.ToTable("Titles").PrimaryColumn("Id");
Delete.ForeignKey()
.FromTable("Users").ForeignColumn("LanguageId")
.ToTable("Languages").PrimaryColumn("Id");
Delete.ForeignKey()
.FromTable("UserDisciplines").ForeignColumn("DisciplineId")
.ToTable("Disciplines").PrimaryColumn("Id");
Delete.ForeignKey()
.FromTable("UserDisciplines").ForeignColumn("UserId")
.ToTable("Users").PrimaryColumn("Id");
#endregion
Delete.Column("TitleId").FromTable("Users");
Delete.Column("LanguageId").FromTable("Users");
Delete.Column("Institute").FromTable("Users");
Delete.Table("Titles");
Delete.Table("Languages");
Delete.Table("UserDisciplines");
}
public override void Up()
{
Create.Table("Titles")
.WithColumn("Id").AsGuid().PrimaryKey().WithDefault(SystemMethods.NewGuid)
.WithColumn("DisplayName").AsString(50).NotNullable();
Insert.IntoTable("Titles").Row(new { DisplayName = "Prof." });
Insert.IntoTable("Titles").Row(new { DisplayName = "Dr." });
Create.Table("Languages")
.WithColumn("Id").AsGuid().PrimaryKey().WithDefault(SystemMethods.NewGuid)
.WithColumn("DisplayName").AsString(50).NotNullable()
.WithColumn("Abbreviation").AsString(50).NotNullable();
Insert.IntoTable("Languages").Row(new { DisplayName = "English", Abbreviation = "en" });
Insert.IntoTable("Languages").Row(new { DisplayName = "Deutsch", Abbreviation = "de" });
Create.Table("UserDisciplines")
.WithColumn("RelationId").AsGuid().PrimaryKey().WithDefault(SystemMethods.NewGuid)
.WithColumn("DisciplineId").AsGuid().NotNullable()
.WithColumn("UserId").AsGuid().NotNullable();
Alter.Table("Users").AddColumn("TitleId").AsGuid().Nullable();
Alter.Table("Users").AddColumn("LanguageId").AsGuid().Nullable();
Alter.Table("Users").AddColumn("Institute").AsString(200).Nullable();
#region Foreign Keys
Create.ForeignKey()
.FromTable("Users").ForeignColumn("TitleId")
.ToTable("Titles").PrimaryColumn("Id");
Create.ForeignKey()
.FromTable("Users").ForeignColumn("LanguageId")
.ToTable("Languages").PrimaryColumn("Id");
Create.ForeignKey()
.FromTable("UserDisciplines").ForeignColumn("DisciplineId")
.ToTable("Disciplines").PrimaryColumn("Id");
Create.ForeignKey()
.FromTable("UserDisciplines").ForeignColumn("UserId")
.ToTable("Users").PrimaryColumn("Id");
#endregion
}
}
}
......@@ -169,6 +169,7 @@
<Compile Include="Migrations\Migration202002101300MoreLicenses.cs" />
<Compile Include="Migrations\Migration202003231800Organizations.cs" />
<Compile Include="Migrations\Migration202003121255ActivatedFeatures.cs" />
<Compile Include="Migrations\Migration202005151300ExtendUser.cs" />
<Compile Include="Migrations\Migration202004151354S3ResourceUrl.cs" />
<Compile Include="Migrations\Migration202003192117ORCiDEmailAddress.cs" />
<Compile Include="Migrator.cs" />
......
......@@ -11,6 +11,6 @@ using System.Reflection;
[assembly: AssemblyProduct("Migrator")]
[assembly: AssemblyVersion("1.4.0")]
[assembly: AssemblyFileVersion("1.4.0")]
[assembly: AssemblyInformationalVersion("1.4.0-topic-804-nicepr0001")]
[assembly: AssemblyInformationalVersion("1.4.0-topic-758-userpr0001")]
[assembly: AssemblyCopyright("2020 IT Center, RWTH Aachen University")]
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