Skip to content
Snippets Groups Projects
Commit 8abd1574 authored by Marcel Nellesen's avatar Marcel Nellesen
Browse files

Merge branch 'Product/512-apiRefactor' into 'Sprint/2020-03'

Product/512 api refactor

See merge request coscine/cs/migrations!3
parents fd793fb5 a5d1026a
No related branches found
No related tags found
2 merge requests!3Product/512 api refactor,!2Sprint/2020-03
Showing
with 4299 additions and 52 deletions
stages:
- test
- docs
- release
- releasetrigger
......@@ -19,19 +18,11 @@ cake:Test:
- master
- tags
docs:
stage: docs
script:
- .\publishDocs.ps1 $GITLAB_TOKEN
variables:
GIT_STRATEGY: clone
only:
- tags
cake:Release:
stage: release
script:
- PowerShell .\build.ps1 -Target Release -Configuration Release --nugetApiKey="${NUGET_API_KEY}"
- PowerShell .\src\Migrator\bin\Release\Migrator.exe --migrate_up
variables:
GIT_STRATEGY: clone
dependencies:
......
{
"plugins": [
["@semantic-release/commit-analyzer", {
"preset": "eslint"
}],
["@semantic-release/release-notes-generator", {
"preset": "eslint",
}],
["@semantic-release/gitlab", {
"preset": "eslint",
"gitlabUrl": "https://git.rwth-aachen.de"
}],
["@semantic-release/exec", {
"prepareCmd" : "echo ${nextRelease.version}",
"publishCmd" : "echo test"
}],
["@semantic-release/git", {
"preset": "eslint",
"assets": "src/**/Properties/AssemblyInfo.cs",
"message": "Chore: ${nextRelease.version}\n\n${nextRelease.notes}"
}]
]
}
param(
$token
)
$remoteUrl = git config --get remote.origin.url
$remoteUrl = $remoteUrl.replace("git@", "")
$remoteUrl = $remoteUrl -replace "https(.*?)@",""
$remoteUrl = $remoteUrl.replace(":", "/")
$remoteUrl = $remoteUrl.replace(".git", ".wiki.git")
$temporaryFolderName = "publishDocsTempFolder"
git clone "https://gitlab-ci-token:$($token)@$($remoteUrl)" $temporaryFolderName
cd $temporaryFolderName
Remove-Item *
cp -r ../docs/* ./
git add .
git commit -m "Docs: Documentation Update"
git push
\ No newline at end of file

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.156
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Migrator", "Migrator\Migrator.csproj", "{A48A255E-D08A-4336-B481-266DEBFABDE9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A48A255E-D08A-4336-B481-266DEBFABDE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A48A255E-D08A-4336-B481-266DEBFABDE9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A48A255E-D08A-4336-B481-266DEBFABDE9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A48A255E-D08A-4336-B481-266DEBFABDE9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2B54411D-F046-46C3-940F-45B5BBD051CF}
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
\ No newline at end of file
This diff is collapsed.
<?xml version="1.0" encoding="utf-8" ?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<rdf:Description rdf:about="https://spdx.org/licenses/Apache-2.0">
<rdf:about>https://spdx.org/licenses/Apache-2.0</rdf:about>
<rdfs:label xml:lang="en">Apache License 2.0</rdfs:label>
<rdf:resource>http://purl.org/dc/terms/LicenseDocument</rdf:resource>
<rdf:resource>http://purl.org/dc/terms/RightsDocument</rdf:resource>
<rdf:type rdf:resource="https://spdx.org/licenses/"/>
</rdf:Description>
<rdf:Description rdf:about="https://spdx.org/licenses/GPL-3.0+">
<rdf:about>https://spdx.org/licenses/GPL-3.0+</rdf:about>
<rdfs:label xml:lang="en">GNU General Public License v3.0</rdfs:label>
<rdf:resource>http://purl.org/dc/terms/LicenseDocument</rdf:resource>
<rdf:resource>http://purl.org/dc/terms/RightsDocument</rdf:resource>
<rdf:type rdf:resource="https://spdx.org/licenses/"/>
</rdf:Description>
<rdf:Description rdf:about="https://spdx.org/licenses/MIT">
<rdf:about>https://spdx.org/licenses/MIT</rdf:about>
<rdfs:label xml:lang="en">MIT License</rdfs:label>
<rdf:resource>http://purl.org/dc/terms/LicenseDocument</rdf:resource>
<rdf:resource>http://purl.org/dc/terms/RightsDocument</rdf:resource>
<rdf:type rdf:resource="https://spdx.org/licenses/"/>
</rdf:Description>
<rdf:Description rdf:about="https://spdx.org/licenses/BSD-2-Clause">
<rdf:about>https://spdx.org/licenses/BSD-2-Clause</rdf:about>
<rdfs:label xml:lang="en">BSD 2-clause 'Simplified' License</rdfs:label>
<rdf:resource>http://purl.org/dc/terms/LicenseDocument</rdf:resource>
<rdf:resource>http://purl.org/dc/terms/RightsDocument</rdf:resource>
<rdf:type rdf:resource="https://spdx.org/licenses/"/>
</rdf:Description>
<rdf:Description rdf:about="https://spdx.org/licenses/BSD-3-Clause">
<rdf:about>https://spdx.org/licenses/BSD-3-Clause</rdf:about>
<rdfs:label xml:lang="en">BSD 3-clause 'New' or 'Revised' License</rdfs:label>
<rdf:resource>http://purl.org/dc/terms/LicenseDocument</rdf:resource>
<rdf:resource>http://purl.org/dc/terms/RightsDocument</rdf:resource>
<rdf:type rdf:resource="https://spdx.org/licenses/"/>
</rdf:Description>
<rdf:Description rdf:about="https://spdx.org/licenses/EPL-1.0">
<rdf:about>https://spdx.org/licenses/EPL-1.0</rdf:about>
<rdfs:label xml:lang="en">Eclipse Public License 1.0</rdfs:label>
<rdf:resource>http://purl.org/dc/terms/LicenseDocument</rdf:resource>
<rdf:resource>http://purl.org/dc/terms/RightsDocument</rdf:resource>
<rdf:type rdf:resource="https://spdx.org/licenses/"/>
</rdf:Description>
<rdf:Description rdf:about="https://spdx.org/licenses/GPL-3.0">
<rdf:about>https://spdx.org/licenses/AGPL-3.0</rdf:about>
<rdfs:label xml:lang="en">GNU Affero General Public License v3.0</rdfs:label>
<rdf:resource>http://purl.org/dc/terms/LicenseDocument</rdf:resource>
<rdf:resource>http://purl.org/dc/terms/RightsDocument</rdf:resource>
<rdf:type rdf:resource="https://spdx.org/licenses/"/>
</rdf:Description>
<rdf:Description rdf:about="https://spdx.org/licenses/GPL-2.0">
<rdf:about>https://spdx.org/licenses/GPL-2.0</rdf:about>
<rdfs:label xml:lang="en">GNU General Public License v2.0</rdfs:label>
<rdf:resource>http://purl.org/dc/terms/LicenseDocument</rdf:resource>
<rdf:resource>http://purl.org/dc/terms/RightsDocument</rdf:resource>
<rdf:type rdf:resource="https://spdx.org/licenses/"/>
</rdf:Description>
<rdf:Description rdf:about="https://spdx.org/licenses/LGPL-2.1">
<rdf:about>https://spdx.org/licenses/LGPL-2.1</rdf:about>
<rdfs:label xml:lang="en">GNU Lesser General Public License v2.1</rdfs:label>
<rdf:resource>http://purl.org/dc/terms/LicenseDocument</rdf:resource>
<rdf:resource>http://purl.org/dc/terms/RightsDocument</rdf:resource>
<rdf:type rdf:resource="https://spdx.org/licenses/"/>
</rdf:Description>
<rdf:Description rdf:about="https://spdx.org/licenses/LGPL-3.0">
<rdf:about>https://spdx.org/licenses/LGPL-3.0</rdf:about>
<rdfs:label xml:lang="en">GNU Lesser General Public License v3.0</rdfs:label>
<rdf:resource>http://purl.org/dc/terms/LicenseDocument</rdf:resource>
<rdf:resource>http://purl.org/dc/terms/RightsDocument</rdf:resource>
<rdf:type rdf:resource="https://spdx.org/licenses/"/>
</rdf:Description>
<rdf:Description rdf:about="https://spdx.org/licenses/MPL-2.0">
<rdf:about>https://spdx.org/licenses/MPL-2.0</rdf:about>
<rdfs:label xml:lang="en">Mozilla Public License 2.0</rdfs:label>
<rdf:resource>http://purl.org/dc/terms/LicenseDocument</rdf:resource>
<rdf:resource>http://purl.org/dc/terms/RightsDocument</rdf:resource>
<rdf:type rdf:resource="https://spdx.org/licenses/"/>
</rdf:Description>
<rdf:Description rdf:about="https://spdx.org/licenses/Unlicense">
<rdf:about>https://spdx.org/licenses/Unlicense</rdf:about>
<rdfs:label xml:lang="en">The Unlicense</rdfs:label>
<rdf:resource>http://purl.org/dc/terms/LicenseDocument</rdf:resource>
<rdf:resource>http://purl.org/dc/terms/RightsDocument</rdf:resource>
<rdf:type rdf:resource="https://spdx.org/licenses/"/>
</rdf:Description>
</rdf:RDF>
\ No newline at end of file
This diff is collapsed.
using FluentMigrator;
namespace Coscine.Database.Migration.Migrations
{
//yyyymmddhhmm
[Migration(201907011352)]
public class Migration201907011352ProjectApi : FluentMigrator.Migration
{
public override void Down()
{
#region Foreign Keys
Delete.ForeignKey()
.FromTable("Resources").ForeignColumn("TypeId")
.ToTable("ResourceTypes").PrimaryColumn("Id");
Delete.ForeignKey()
.FromTable("SubProjects").ForeignColumn("ProjectId")
.ToTable("Projects").PrimaryColumn("Id");
Delete.ForeignKey()
.FromTable("SubProjects").ForeignColumn("SubProjectId")
.ToTable("Projects").PrimaryColumn("Id");
Delete.ForeignKey()
.FromTable("ProjectResource").ForeignColumn("ResourceId")
.ToTable("Resources").PrimaryColumn("Id");
Delete.ForeignKey()
.FromTable("ProjectResource").ForeignColumn("ProjectId")
.ToTable("Projects").PrimaryColumn("Id");
Delete.ForeignKey()
.FromTable("ProjectRoles").ForeignColumn("ProjectId")
.ToTable("Projects").PrimaryColumn("Id");
Delete.ForeignKey()
.FromTable("ProjectRoles").ForeignColumn("UserId")
.ToTable("Users").PrimaryColumn("Id");
Delete.ForeignKey()
.FromTable("ProjectRoles").ForeignColumn("RoleId")
.ToTable("Roles").PrimaryColumn("Id");
#endregion
#region Tables
Delete.Table("ResourceTypes");
Delete.Table("Projects");
Delete.Table("Users");
Delete.Table("Roles");
Delete.Table("Resources");
Delete.Table("SubProjects");
Delete.Table("ProjectResource");
Delete.Table("ProjectRoles");
#endregion
}
public override void Up()
{
#region Independent Tables
Create.Table("ResourceTypes")
.WithColumn("Id").AsGuid().PrimaryKey().WithDefault(SystemMethods.NewGuid)
.WithColumn("DisplayName").AsString(50).NotNullable();
Create.Table("Projects")
.WithColumn("Id").AsGuid().PrimaryKey().WithDefault(SystemMethods.NewGuid)
.WithColumn("DisplayName").AsString(200).NotNullable()
.WithColumn("Description").AsString(1000).NotNullable()
.WithColumn("Organization").AsString(50).NotNullable();
Create.Table("Users")
.WithColumn("Id").AsGuid().PrimaryKey().WithDefault(SystemMethods.NewGuid);
Create.Table("Roles")
.WithColumn("Id").AsGuid().PrimaryKey().WithDefault(SystemMethods.NewGuid)
.WithColumn("DisplayName").AsString(50).NotNullable()
.WithColumn("Description").AsString(50).NotNullable();
Insert.IntoTable("Roles").Row(new { DisplayName = "Owner", Description = "Owner of the project." });
Insert.IntoTable("Roles").Row(new { DisplayName = "Member", Description = "Member of the project." });
#endregion
#region Resources
Create.Table("Resources")
.WithColumn("Id").AsGuid().PrimaryKey().WithDefault(SystemMethods.NewGuid)
.WithColumn("Url").AsString(200).NotNullable()
.WithColumn("ExternalId").AsString(200).NotNullable()
.WithColumn("TypeId").AsGuid().NotNullable();
Create.ForeignKey()
.FromTable("Resources").ForeignColumn("TypeId")
.ToTable("ResourceTypes").PrimaryColumn("Id");
#endregion
#region SubProjects
Create.Table("SubProjects")
.WithColumn("RelationId").AsGuid().PrimaryKey().WithDefault(SystemMethods.NewGuid)
.WithColumn("ProjectId").AsGuid().NotNullable()
.WithColumn("SubProjectId").AsGuid().NotNullable();
Create.ForeignKey()
.FromTable("SubProjects").ForeignColumn("ProjectId")
.ToTable("Projects").PrimaryColumn("Id");
Create.ForeignKey()
.FromTable("SubProjects").ForeignColumn("SubProjectId")
.ToTable("Projects").PrimaryColumn("Id");
#endregion
#region ProjectResource
Create.Table("ProjectResource")
.WithColumn("RelationId").AsGuid().PrimaryKey().WithDefault(SystemMethods.NewGuid)
.WithColumn("ResourceId").AsGuid().NotNullable()
.WithColumn("ProjectId").AsGuid().NotNullable();
Create.ForeignKey()
.FromTable("ProjectResource").ForeignColumn("ResourceId")
.ToTable("Resources").PrimaryColumn("Id");
Create.ForeignKey()
.FromTable("ProjectResource").ForeignColumn("ProjectId")
.ToTable("Projects").PrimaryColumn("Id");
#endregion
#region ProjectRoles
Create.Table("ProjectRoles")
.WithColumn("RelationId").AsGuid().PrimaryKey().WithDefault(SystemMethods.NewGuid)
.WithColumn("ProjectId").AsGuid().NotNullable()
.WithColumn("UserId").AsGuid().NotNullable()
.WithColumn("RoleId").AsGuid().NotNullable();
Create.ForeignKey()
.FromTable("ProjectRoles").ForeignColumn("ProjectId")
.ToTable("Projects").PrimaryColumn("Id");
Create.ForeignKey()
.FromTable("ProjectRoles").ForeignColumn("UserId")
.ToTable("Users").PrimaryColumn("Id");
Create.ForeignKey()
.FromTable("ProjectRoles").ForeignColumn("RoleId")
.ToTable("Roles").PrimaryColumn("Id");
#endregion
}
}
}
using FluentMigrator;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Coscine.Database.Migration.Migrations
{
//yyyymmddhhmm
[Migration(201907081510)]
public class Migration201907081510EnhanceProjectApi : FluentMigrator.Migration
{
public override void Down()
{
Delete.Column("StartDate").FromTable("Projects");
Delete.Column("EndDate").FromTable("Projects");
Delete.Column("Keywords").FromTable("Projects");
}
public override void Up()
{
Alter.Table("Projects")
.AddColumn("StartDate").AsDateTime().WithDefault(SystemMethods.CurrentDateTime)
.AddColumn("EndDate").AsDateTime()
.AddColumn("Keywords").AsString(1000);
}
}
}
using FluentMigrator;
namespace Coscine.Database.Migration.Migrations
{
//yyyymmddhhmm
[Migration(201907100900)]
public class Migration201907100900UserProfilesApi : FluentMigrator.Migration
{
public override void Down()
{
#region Foreign Keys
Delete.ForeignKey()
.FromTable("GroupMemberships").ForeignColumn("UserId")
.ToTable("Users").PrimaryColumn("Id");
Delete.ForeignKey()
.FromTable("GroupMemberships").ForeignColumn("GroupId")
.ToTable("Groups").PrimaryColumn("Id");
Delete.ForeignKey()
.FromTable("ExternalIds").ForeignColumn("UserId")
.ToTable("Users").PrimaryColumn("Id");
Delete.ForeignKey()
.FromTable("ExternalIds").ForeignColumn("ResourceTypeId")
.ToTable("ExternalAuthenticators").PrimaryColumn("Id");
#endregion
#region Tables
Delete.Table("Groups");
Delete.Table("GroupMemberships");
Delete.Table("ExternalAuthenticators");
Delete.Table("ExternalIds");
#endregion
#region Columns
Delete.Column("EmailAddress").FromTable("Users");
Delete.Column("DisplayName").FromTable("Users");
#endregion
}
public override void Up()
{
#region Existing Tables
Alter.Table("Users")
.AddColumn("EmailAddress").AsString(255).NotNullable()
.AddColumn("DisplayName").AsString(255).NotNullable();
#endregion
#region Independent Tables
Create.Table("Groups")
.WithColumn("Id").AsGuid().PrimaryKey().WithDefault(SystemMethods.NewGuid)
.WithColumn("DisplayName").AsString(255).NotNullable();
Create.Table("ExternalAuthenticators")
.WithColumn("Id").AsGuid().PrimaryKey().WithDefault(SystemMethods.NewGuid)
.WithColumn("DisplayName").AsString(50).NotNullable();
#endregion
#region GroupMemberships
Create.Table("GroupMemberships")
.WithColumn("RelationId").AsGuid().PrimaryKey().WithDefault(SystemMethods.NewGuid)
.WithColumn("GroupId").AsGuid().NotNullable()
.WithColumn("UserId").AsGuid().NotNullable();
Create.ForeignKey()
.FromTable("GroupMemberships").ForeignColumn("UserId")
.ToTable("Users").PrimaryColumn("Id");
Create.ForeignKey()
.FromTable("GroupMemberships").ForeignColumn("GroupId")
.ToTable("Groups").PrimaryColumn("Id");
#endregion
#region ExternalIds
Create.Table("ExternalIds")
.WithColumn("RelationId").AsGuid().PrimaryKey().WithDefault(SystemMethods.NewGuid)
.WithColumn("UserId").AsGuid().NotNullable()
.WithColumn("ResourceTypeId").AsGuid().NotNullable()
.WithColumn("ExternalId").AsString(255);
Create.ForeignKey()
.FromTable("ExternalIds").ForeignColumn("UserId")
.ToTable("Users").PrimaryColumn("Id");
Create.ForeignKey()
.FromTable("ExternalIds").ForeignColumn("ResourceTypeId")
.ToTable("ExternalAuthenticators").PrimaryColumn("Id");
#endregion
}
}
}
using FluentMigrator;
namespace Coscine.Database.Migration.Migrations
{
//yyyymmddhhmm
[Migration(201908071616)]
public class Migration201908071616RdsResource : FluentMigrator.Migration
{
public override void Down()
{
Delete.FromTable("ResourceTypes").Row(new { DisplayName = "rds" });
}
public override void Up()
{
Insert.IntoTable("ResourceTypes").Row(new { DisplayName = "rds" });
}
}
}
using FluentMigrator;
namespace Coscine.Database.Migration.Migrations
{
//yyyymmddhhmm
[Migration(201908121401)]
public class Migration201908121401GitlabResource : FluentMigrator.Migration
{
public override void Down()
{
Delete.FromTable("ResourceTypes").Row(new { DisplayName = "gitlab" });
}
public override void Up()
{
Insert.IntoTable("ResourceTypes").Row(new { DisplayName = "gitlab" });
}
}
}
using FluentMigrator;
namespace Coscine.Database.Migration.Migrations
{
//yyyymmddhhmm
[Migration(201908231520)]
public class Migration201908231520ResourceDisplayName : FluentMigrator.Migration
{
public override void Down()
{
Delete.Column("DisplayName").FromTable("Resources");
}
public override void Up()
{
Alter.Table("Resources").AddColumn("DisplayName").AsString(200).Nullable();
}
}
}
using FluentMigrator;
namespace Coscine.Database.Migration.Migrations
{
//yyyymmddhhmm
[Migration(201908290941)]
public class Migration201908290941ORCiD : FluentMigrator.Migration
{
public override void Down()
{
Rename.Column("ExternalAuthenticatorId").OnTable("ExternalIds").To("ResourceTypeId");
Delete.FromTable("ExternalAuthenticators").Row(new { DisplayName = "ORCiD" });
}
public override void Up()
{
Rename.Column("ResourceTypeId").OnTable("ExternalIds").To("ExternalAuthenticatorId");
Insert.IntoTable("ExternalAuthenticators").Row(new { DisplayName = "ORCiD" });
}
}
}
using FluentMigrator;
namespace Coscine.Database.Migration.Migrations
{
//yyyymmddhhmm
[Migration(201909111125)]
public class Migration201909111125ProjectEnhancement : FluentMigrator.Migration
{
public override void Down()
{
#region Foreign Keys
Delete.ForeignKey()
.FromTable("ProjectDiscipline").ForeignColumn("DisciplineId")
.ToTable("Disciplines").PrimaryColumn("Id");
Delete.ForeignKey()
.FromTable("ProjectDiscipline").ForeignColumn("ProjectId")
.ToTable("Projects").PrimaryColumn("Id");
Delete.ForeignKey()
.FromTable("ProjectInstitute").ForeignColumn("InstituteId")
.ToTable("Institutes").PrimaryColumn("Id");
Delete.ForeignKey()
.FromTable("ProjectInstitute").ForeignColumn("ProjectId")
.ToTable("Projects").PrimaryColumn("Id");
Delete.ForeignKey()
.FromTable("Projects").ForeignColumn("VisibilityId")
.ToTable("Visibilities").PrimaryColumn("Id");
#endregion
Delete.Column("DisplayName").FromTable("Projects");
Delete.Column("PrincipleInvestigators").FromTable("Projects");
Delete.Column("GrantId").FromTable("Projects");
Alter.Table("Projects").AlterColumn("Description").AsString(1000).NotNullable();
Rename.Column("ProjectName").OnTable("Projects").To("DisplayName");
Delete.Column("VisibilityId").FromTable("Projects");
Delete.Table("ProjectDiscipline");
Delete.Table("Disciplines");
Delete.Table("ProjectInstitute");
Delete.Table("Institutes");
Delete.Table("Visibilities");
Alter.Table("Projects").AddColumn("Organization").AsString(50).Nullable();
}
public override void Up()
{
Rename.Column("DisplayName").OnTable("Projects").To("ProjectName");
Delete.Column("Organization").FromTable("Projects");
Alter.Table("Projects").AlterColumn("Description").AsString(5000).NotNullable();
Alter.Table("Projects").AddColumn("DisplayName").AsString(25).Nullable();
Alter.Table("Projects").AddColumn("PrincipleInvestigators").AsString(500).Nullable();
Alter.Table("Projects").AddColumn("GrantId").AsString(500).Nullable();
Create.Table("Disciplines")
.WithColumn("Id").AsGuid().PrimaryKey().WithDefault(SystemMethods.NewGuid)
.WithColumn("DisplayName").AsString(200).NotNullable()
.WithColumn("Url").AsString(200).NotNullable();
Create.Table("ProjectDiscipline")
.WithColumn("RelationId").AsGuid().PrimaryKey().WithDefault(SystemMethods.NewGuid)
.WithColumn("DisciplineId").AsGuid().NotNullable()
.WithColumn("ProjectId").AsGuid().NotNullable();
Create.ForeignKey()
.FromTable("ProjectDiscipline").ForeignColumn("DisciplineId")
.ToTable("Disciplines").PrimaryColumn("Id");
Create.ForeignKey()
.FromTable("ProjectDiscipline").ForeignColumn("ProjectId")
.ToTable("Projects").PrimaryColumn("Id");
Create.Table("Institutes")
.WithColumn("Id").AsGuid().PrimaryKey().WithDefault(SystemMethods.NewGuid)
.WithColumn("DisplayName").AsString(200).NotNullable()
.WithColumn("IKZ").AsString(20).NotNullable();
Create.Table("ProjectInstitute")
.WithColumn("RelationId").AsGuid().PrimaryKey().WithDefault(SystemMethods.NewGuid)
.WithColumn("InstituteId").AsGuid().NotNullable()
.WithColumn("ProjectId").AsGuid().NotNullable();
Create.ForeignKey()
.FromTable("ProjectInstitute").ForeignColumn("InstituteId")
.ToTable("Institutes").PrimaryColumn("Id");
Create.ForeignKey()
.FromTable("ProjectInstitute").ForeignColumn("ProjectId")
.ToTable("Projects").PrimaryColumn("Id");
Alter.Table("Projects").AddColumn("VisibilityId").AsGuid().Nullable();
Create.Table("Visibilities")
.WithColumn("Id").AsGuid().PrimaryKey().WithDefault(SystemMethods.NewGuid)
.WithColumn("DisplayName").AsString(50).NotNullable();
Insert.IntoTable("Visibilities").Row(new { DisplayName = "Project Members" });
Insert.IntoTable("Visibilities").Row(new { DisplayName = "Public" });
Create.ForeignKey()
.FromTable("Projects").ForeignColumn("VisibilityId")
.ToTable("Visibilities").PrimaryColumn("Id");
Alter.Column("Keywords").OnTable("Projects").AsString(1000).Nullable();
}
}
}
using FluentMigrator;
namespace Coscine.Database.Migration.Migrations
{
//yyyymmddhhmm
[Migration(201909160919)]
public class Migration201909160919UserEnhancement : FluentMigrator.Migration
{
public override void Down()
{
Delete.Column("Givenname").FromTable("Users");
Delete.Column("Surname").FromTable("Users");
}
public override void Up()
{
Alter.Table("Users").AddColumn("Givenname").AsString(200).Nullable();
Alter.Table("Users").AddColumn("Surname").AsString(200).Nullable();
}
}
}
using FluentMigrator;
namespace Coscine.Database.Migration.Migrations
{
//yyyymmddhhmm
[Migration(201909190938)]
public class Migration201909190938ResourceEnhancement : FluentMigrator.Migration
{
public override void Down()
{
#region Foreign Keys
Delete.ForeignKey()
.FromTable("ResourceDiscipline").ForeignColumn("DisciplineId")
.ToTable("Disciplines").PrimaryColumn("Id");
Delete.ForeignKey()
.FromTable("ResourceDiscipline").ForeignColumn("ResourceId")
.ToTable("Resources").PrimaryColumn("Id");
Delete.ForeignKey()
.FromTable("Resources").ForeignColumn("VisibilityId")
.ToTable("Visibilities").PrimaryColumn("Id");
Delete.ForeignKey()
.FromTable("Resources").ForeignColumn("LicenseId")
.ToTable("Licenses").PrimaryColumn("Id");
#endregion
Delete.Column("DisplayName").FromTable("Resources");
Rename.Column("ResourceName").OnTable("Resources").To("DisplayName");
Delete.Column("VisibilityId").FromTable("Resources");
Delete.Column("LicenseId").FromTable("Resources");
Delete.Column("Keywords").FromTable("Resources");
Delete.Column("UsageRights").FromTable("Resources");
Delete.Column("ResourceTypeOptionId").FromTable("Resources");
Alter.Table("Resources")
.AddColumn("Url").AsString(200).Nullable()
.AddColumn("ExternalId").AsString(200).Nullable();
Delete.Table("ResourceDiscipline");
Delete.Table("Licenses");
Delete.Table("RDSResourceType");
Delete.Table("GitlabResourceType");
}
public override void Up()
{
Rename.Column("DisplayName").OnTable("Resources").To("ResourceName");
Alter.Table("Resources").AddColumn("DisplayName").AsString(25).Nullable();
Create.Table("ResourceDiscipline")
.WithColumn("RelationId").AsGuid().PrimaryKey().WithDefault(SystemMethods.NewGuid)
.WithColumn("DisciplineId").AsGuid().NotNullable()
.WithColumn("ResourceId").AsGuid().NotNullable();
Create.ForeignKey()
.FromTable("ResourceDiscipline").ForeignColumn("DisciplineId")
.ToTable("Disciplines").PrimaryColumn("Id");
Create.ForeignKey()
.FromTable("ResourceDiscipline").ForeignColumn("ResourceId")
.ToTable("Resources").PrimaryColumn("Id");
Alter.Table("Resources").AddColumn("VisibilityId").AsGuid().Nullable();
Create.ForeignKey()
.FromTable("Resources").ForeignColumn("VisibilityId")
.ToTable("Visibilities").PrimaryColumn("Id");
Alter.Table("Resources").AddColumn("LicenseId").AsGuid().Nullable();
Create.Table("Licenses")
.WithColumn("Id").AsGuid().PrimaryKey().WithDefault(SystemMethods.NewGuid)
.WithColumn("DisplayName").AsString(50).NotNullable();
Create.ForeignKey()
.FromTable("Resources").ForeignColumn("LicenseId")
.ToTable("Licenses").PrimaryColumn("Id");
Alter.Table("Resources").AddColumn("Keywords").AsString(1000).Nullable();
Alter.Table("Resources").AddColumn("UsageRights").AsString(200).Nullable();
Create.Table("RDSResourceType")
.WithColumn("Id").AsGuid().PrimaryKey().WithDefault(SystemMethods.NewGuid)
.WithColumn("BucketName").AsString(63).NotNullable()
.WithColumn("AccessKey").AsString(200).Nullable()
.WithColumn("SecretKey").AsString(200).Nullable();
Create.Table("GitlabResourceType")
.WithColumn("Id").AsGuid().PrimaryKey().WithDefault(SystemMethods.NewGuid)
.WithColumn("RepositoryNumber").AsInt32().NotNullable()
.WithColumn("RepositoryUrl").AsString(500).NotNullable()
.WithColumn("Token").AsString(100).NotNullable();
Alter.Table("Resources").AddColumn("ResourceTypeOptionId").AsGuid().Nullable();
Delete.Column("ExternalId").FromTable("Resources");
Delete.Column("Url").FromTable("Resources");
}
}
}
using FluentMigrator;
namespace Coscine.Database.Migration.Migrations
{
//yyyymmddhhmm
[Migration(201910021300)]
public class Migration201910021300ResourceDescription : FluentMigrator.Migration
{
public override void Down()
{
Delete.Column("Description").FromTable("Resources");
}
public override void Up()
{
Alter.Table("Resources").AddColumn("Description").AsString(5000).Nullable();
}
}
}
using FluentMigrator;
using System;
using System.IO;
using System.Reflection;
using System.Xml;
using System.Xml.Linq;
namespace Coscine.Database.Migration.Migrations
{
//yyyymmddhhmm
[Migration(201910161154)]
public class Migration201910161154InstitutesDisciplines : FluentMigrator.Migration
{
public override void Down()
{
HandleInstitute((obj) => Delete.FromTable("Institutes").Row(obj));
HandleDiscipline((obj) => Delete.FromTable("Disciplines").Row(obj));
}
public override void Up()
{
HandleInstitute((obj) => Insert.IntoTable("Institutes").Row(obj));
HandleDiscipline((obj) => Insert.IntoTable("Disciplines").Row(obj));
}
private void HandleInstitute(Action<object> action)
{
var assembly = Assembly.GetExecutingAssembly();
var resourceName = "Coscine.Database.Migration.Assets.Institutes.csv";
using (var stream = assembly.GetManifestResourceStream(resourceName))
using (var reader = new StreamReader(stream))
{
while (!reader.EndOfStream)
{
var line = reader.ReadLine();
if (line.Contains(","))
{
var values = line.Split(',');
if (values[0].Trim() != "" && values[1].Trim() != "")
{
action.Invoke(new { IKZ = values[0].Trim(), DisplayName = values[1].Trim() });
}
}
}
}
}
private void HandleDiscipline(Action<object> action)
{
var assembly = Assembly.GetExecutingAssembly();
var resourceName = "Coscine.Database.Migration.Assets.dfg_structure.rdf";
using (var stream = assembly.GetManifestResourceStream(resourceName))
using (XmlReader reader = XmlReader.Create(stream))
{
reader.MoveToContent();
XNamespace skosNameSpace = "http://www.w3.org/2004/02/skos/core#";
XNamespace rdfNameSpace = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
if (reader.Name == "skos:Concept")
{
XElement el = (XElement) XNode.ReadFrom(reader);
var notation = el.Element(skosNameSpace + "notation");
if (int.TryParse(notation.Value, out int val) && notation.Value.Length == 3)
{
var url = el.Attribute(rdfNameSpace + "about").Value;
action.Invoke(new { DisplayName = el.Element(skosNameSpace + "prefLabel").Value, Url = url });
}
}
}
}
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment