Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Coscine
backend
libraries
Migrations
Commits
6c9b06c7
Commit
6c9b06c7
authored
Sep 22, 2021
by
L. Ellenbeck
Committed by
Benedikt Heinrichs
Sep 22, 2021
Browse files
New: Migration for ude and rds saves config in table
parent
2fdf6aa3
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/Migrations/Migrations.csproj
View file @
6c9b06c7
...
@@ -17,6 +17,8 @@
...
@@ -17,6 +17,8 @@
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<None Remove="Migrations\Migration202106091057QuotaColumn_up.sql" />
<None Remove="Migrations\Migration202106091057QuotaColumn_up.sql" />
<None Remove="Migrations\Migration202109161043UdeResources_down.sql" />
<None Remove="Migrations\Migration202109161043UdeResources_up.sql" />
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Assets\dfg_structure.rdf" />
<EmbeddedResource Include="Assets\dfg_structure.rdf" />
...
@@ -28,6 +30,8 @@
...
@@ -28,6 +30,8 @@
<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\Migration202109161043UdeResources_down.sql" />
<EmbeddedResource Include="Migrations\Migration202109161043UdeResources_up.sql" />
<EmbeddedResource Include="Migrations\Migration202106091057QuotaColumn_up.sql" />
<EmbeddedResource Include="Migrations\Migration202106091057QuotaColumn_up.sql" />
<EmbeddedResource Include="Migrations\Migration202104010900RdsS3Fix_up.sql" />
<EmbeddedResource Include="Migrations\Migration202104010900RdsS3Fix_up.sql" />
</ItemGroup>
</ItemGroup>
...
...
src/Migrations/Migrations/Migration202109161043UdeResources.cs
0 → 100644
View file @
6c9b06c7
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"
);
}
}
}
src/Migrations/Migrations/Migration202109161043UdeResources_down.sql
0 → 100644
View file @
6c9b06c7
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
src/Migrations/Migrations/Migration202109161043UdeResources_up.sql
0 → 100644
View file @
6c9b06c7
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
src/Migrator/Properties/launchSettings.json
View file @
6c9b06c7
...
@@ -3,6 +3,14 @@
...
@@ -3,6 +3,14 @@
"Migrator"
:
{
"Migrator"
:
{
"commandName"
:
"Project"
,
"commandName"
:
"Project"
,
"commandLineArgs"
:
"--migrate_up"
"commandLineArgs"
:
"--migrate_up"
},
"Migrator up"
:
{
"commandName"
:
"Project"
,
"commandLineArgs"
:
"--migrate_up"
},
"Migrator down"
:
{
"commandName"
:
"Project"
,
"commandLineArgs"
:
"--roll_back 1"
}
}
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment