Commit 12dd989b authored by L. Ellenbeck's avatar L. Ellenbeck Committed by Petar Hristov
Browse files

NEW: Max quota column coscine/issues#1567

parent c6ef9ccc
...@@ -15,6 +15,9 @@ ...@@ -15,6 +15,9 @@
<PackageProjectUrl>https://git.rwth-aachen.de/coscine/backend/libraries/Migrations</PackageProjectUrl> <PackageProjectUrl>https://git.rwth-aachen.de/coscine/backend/libraries/Migrations</PackageProjectUrl>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance> <PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<None Remove="Migrations\Migration202106091057QuotaColumn_up.sql" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Assets\dfg_structure.rdf" /> <EmbeddedResource Include="Assets\dfg_structure.rdf" />
<EmbeddedResource Include="Assets\Institutes.csv" /> <EmbeddedResource Include="Assets\Institutes.csv" />
...@@ -25,6 +28,7 @@ ...@@ -25,6 +28,7 @@
<EmbeddedResource Include="Migrations\Migration202101181145DFNAAI_up.sql" /> <EmbeddedResource Include="Migrations\Migration202101181145DFNAAI_up.sql" />
<EmbeddedResource Include="Migrations\Migration202102101200RdsS3_down.sql" /> <EmbeddedResource Include="Migrations\Migration202102101200RdsS3_down.sql" />
<EmbeddedResource Include="Migrations\Migration202102101200RdsS3_up.sql" /> <EmbeddedResource Include="Migrations\Migration202102101200RdsS3_up.sql" />
<EmbeddedResource Include="Migrations\Migration202106091057QuotaColumn_up.sql" />
<EmbeddedResource Include="Migrations\Migration202104010900RdsS3Fix_up.sql" /> <EmbeddedResource Include="Migrations\Migration202104010900RdsS3Fix_up.sql" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
......
using FluentMigrator;
namespace Coscine.Migrations.Migrations
{
//yyyymmddhhmm
[Migration(202106091057)]
public class Migration202106091057QuotaColumn : Migration
{
public override void Down()
{
Delete.Column("MaxQuota").FromTable("ProjectQuotas");
}
public override void Up()
{
Alter.Table("ProjectQuotas")
.AddColumn("MaxQuota").AsInt32().WithDefaultValue("0").NotNullable();
Execute.EmbeddedScript("Migration202106091057QuotaColumn_up.sql");
}
}
}
DECLARE @rdsS3Id AS uniqueidentifier
SELECT @rdsS3Id = [Id]
FROM [dbo].[ResourceTypes]
WHERE [DisplayName] = 'rdss3';
DECLARE @rdsId AS uniqueidentifier
SELECT @rdsId = [Id]
FROM [dbo].[ResourceTypes]
WHERE [DisplayName] = 'rds';
UPDATE [dbo].[ProjectQuotas]
SET [MaxQuota] = 100
WHERE [ResourceTypeId] = @rdsId AND [Quota] > 0 AND [Quota] <= 100;
UPDATE [dbo].[ProjectQuotas]
SET [MaxQuota] = [Quota]
WHERE ([ResourceTypeId] = @rdsId OR [ResourceTypeId] = @rdsS3Id) AND [MaxQuota] < [Quota];
{
"profiles": {
"Migrator": {
"commandName": "Project",
"commandLineArgs": "--migrate_up"
}
}
}
\ No newline at end of file
Markdown is supported
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