Commit 585a81cf authored by Benedikt Heinrichs's avatar Benedikt Heinrichs
Browse files

New: Add project quotas definitions (coscine/issues#858)

parent 6a8d49c1
using FluentMigrator;
namespace Coscine.Database.Migration.Migrations
{
//yyyymmddhhmm
[Migration(202006261208)]
public class Migration202006261208ProjectQuotas : FluentMigrator.Migration
{
public override void Down()
{
Delete.Table("ProjectQuotas");
}
public override void Up()
{
Create.Table("ProjectQuotas")
.WithColumn("RelationId").AsGuid().PrimaryKey().WithDefault(SystemMethods.NewGuid)
.WithColumn("ProjectId").AsGuid().NotNullable()
.WithColumn("ResourceTypeId").AsGuid().NotNullable()
.WithColumn("Quota").AsInt32().NotNullable().WithDefaultValue(25);
Create.ForeignKey()
.FromTable("ProjectQuotas").ForeignColumn("ProjectId")
.ToTable("Projects").PrimaryColumn("Id");
Create.ForeignKey()
.FromTable("ProjectQuotas").ForeignColumn("ResourceTypeId")
.ToTable("ResourceTypes").PrimaryColumn("Id");
Execute.EmbeddedScript("Migration202006261208ProjectQuotas_up.sql");
}
}
}
INSERT INTO [Coscine].[dbo].[ProjectQuotas] ([ProjectId], [ResourceTypeId]) (SELECT P.[Id], RT.[Id]
FROM [Coscine].[dbo].[Projects] P, [Coscine].[dbo].[ResourceTypes] RT);
\ No newline at end of file
......@@ -173,6 +173,7 @@
<Compile Include="Migrations\Migration202004151354S3ResourceUrl.cs" />
<Compile Include="Migrations\Migration202003192117ORCiDEmailAddress.cs" />
<Compile Include="Migrations\Migration202005251520TOS.cs" />
<Compile Include="Migrations\Migration202006261208ProjectQuotas.cs" />
<Compile Include="Migrator.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
......@@ -190,6 +191,9 @@
<ItemGroup>
<EmbeddedResource Include="Migrations\Migration202003121255ActivatedFeatures_up.sql" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Migrations\Migration202006261208ProjectQuotas_up.sql" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\FluentMigrator.Runner.SqlServerCe.3.1.3\build\netstandard2.0\FluentMigrator.Runner.SqlServerCe.targets" Condition="Exists('..\packages\FluentMigrator.Runner.SqlServerCe.3.1.3\build\netstandard2.0\FluentMigrator.Runner.SqlServerCe.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
......
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