Commit 2b586214 authored by Benedikt Heinrichs's avatar Benedikt Heinrichs
Browse files

Merge branch 'Topic/1711-extendResourceTypeConfiguration' into...

Merge branch 'Topic/1711-extendResourceTypeConfiguration' into 'Product/1629-onboardingOtherUniversities'

Topic/1711 extend resource type configuration

See merge request !67
parents 2fdf6aa3 6c9b06c7
......@@ -17,6 +17,8 @@
</PropertyGroup>
<ItemGroup>
<None Remove="Migrations\Migration202106091057QuotaColumn_up.sql" />
<None Remove="Migrations\Migration202109161043UdeResources_down.sql" />
<None Remove="Migrations\Migration202109161043UdeResources_up.sql" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Assets\dfg_structure.rdf" />
......@@ -28,6 +30,8 @@
<EmbeddedResource Include="Migrations\Migration202101181145DFNAAI_up.sql" />
<EmbeddedResource Include="Migrations\Migration202102101200RdsS3_down.sql" />
<EmbeddedResource Include="Migrations\Migration202102101200RdsS3_up.sql" />
<EmbeddedResource Include="Migrations\Migration202109161043UdeResources_down.sql" />
<EmbeddedResource Include="Migrations\Migration202109161043UdeResources_up.sql" />
<EmbeddedResource Include="Migrations\Migration202106091057QuotaColumn_up.sql" />
<EmbeddedResource Include="Migrations\Migration202104010900RdsS3Fix_up.sql" />
</ItemGroup>
......
using Coscine.Configuration;
using FluentMigrator;
namespace Coscine.Migrations.Migrations
{
//yyyymmddhhmm
[Migration(202109161043)]
public class Migration202109161043UdeResources : Migration
{
public override void Down()
{
Execute.EmbeddedScript("Migration202109161043UdeResources_down.sql");
Delete.Column("AccessKey").FromTable("RDSResourceType");
Delete.Column("SecretKey").FromTable("RDSResourceType");
Delete.Column("Endpoint").FromTable("RDSResourceType");
Delete.FromTable("ResourceTypes").Row(new { DisplayName = "rdss3ude" });
Delete.FromTable("ResourceTypes").Row(new { DisplayName = "rdsude" });
}
public override void Up()
{
var configuration = new ConsulConfiguration();
// Make nullable, as we extend the table, which already has rows
Alter.Table("RDSResourceType")
.AddColumn("AccessKey").AsString(200).Nullable()
.AddColumn("SecretKey").AsString(200).Nullable()
.AddColumn("Endpoint").AsString(200).Nullable();
// Insert missing data
Update.Table("RDSResourceType").Set(new { AccessKey = configuration.GetString("coscine/global/rds/ecs-rwth/rds/object_user_name") }).AllRows();
Update.Table("RDSResourceType").Set(new { SecretKey = configuration.GetString("coscine/global/rds/ecs-rwth/rds/object_user_secretkey") }).AllRows();
Update.Table("RDSResourceType").Set(new { Endpoint = configuration.GetString("coscine/global/rds/ecs-rwth/rds/s3_endpoint") }).AllRows();
// Make NotNullable
Alter.Table("RDSResourceType")
.AlterColumn("AccessKey").AsString(200).NotNullable()
.AlterColumn("SecretKey").AsString(200).NotNullable()
.AlterColumn("Endpoint").AsString(200).NotNullable();
// Add resourcetypes
Insert.IntoTable("ResourceTypes").Row(new { DisplayName = "rdss3ude" });
Insert.IntoTable("ResourceTypes").Row(new { DisplayName = "rdsude" });
// Add quotas
Execute.EmbeddedScript("Migration202109161043UdeResources_up.sql");
}
}
}
DECLARE @rdsS3udeId AS uniqueidentifier
SELECT @rdsS3udeId = [Id]
FROM [dbo].[ResourceTypes]
WHERE [DisplayName] = 'rdss3ude';
DECLARE @rdsudeId AS uniqueidentifier
SELECT @rdsudeId = [Id]
FROM [dbo].[ResourceTypes]
WHERE [DisplayName] = 'rdsude';
DELETE FROM [dbo].[ProjectQuotas]
WHERE [ResourceTypeId] = @rdsS3udeId OR [ResourceTypeId] = @rdsudeId
\ No newline at end of file
DECLARE @rdsS3udeId AS uniqueidentifier
SELECT @rdsS3udeId = [Id]
FROM [dbo].[ResourceTypes]
WHERE [DisplayName] = 'rdss3ude';
DECLARE @rdsudeId AS uniqueidentifier
SELECT @rdsudeId = [Id]
FROM [dbo].[ResourceTypes]
WHERE [DisplayName] = 'rdsude';
INSERT INTO [ProjectQuotas]
([ProjectId]
,[ResourceTypeId]
,[Quota]
,[MaxQuota])
SELECT [Id], @rdsS3udeId, 0, 0
FROM [Projects]
INSERT INTO [ProjectQuotas]
([ProjectId]
,[ResourceTypeId]
,[Quota]
,[MaxQuota])
SELECT [Id], @rdsudeId, 0, 0
FROM [Projects]
\ No newline at end of file
......@@ -3,6 +3,14 @@
"Migrator": {
"commandName": "Project",
"commandLineArgs": "--migrate_up"
},
"Migrator up": {
"commandName": "Project",
"commandLineArgs": "--migrate_up"
},
"Migrator down": {
"commandName": "Project",
"commandLineArgs": "--roll_back 1"
}
}
}
\ No newline at end of file
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