Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Database
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Coscine
backend
libraries
Database
Commits
00bf9efb
Commit
00bf9efb
authored
6 years ago
by
David Schimmel
Browse files
Options
Downloads
Patches
Plain Diff
Update: Added migration for user profiles (issues/coscine#156)
parent
00d3a970
No related branches found
No related tags found
1 merge request
!10
Product/114 user profile migration
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Migrator/Migrations/Migration201907100900UserProfilesApi.cs
+91
-0
91 additions, 0 deletions
...grator/Migrations/Migration201907100900UserProfilesApi.cs
src/Migrator/Migrator.csproj
+1
-0
1 addition, 0 deletions
src/Migrator/Migrator.csproj
with
92 additions
and
0 deletions
src/Migrator/Migrations/Migration201907100900UserProfilesApi.cs
0 → 100644
+
91
−
0
View file @
00bf9efb
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
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
(
"Name"
).
AsString
(
255
).
NotNullable
();
Create
.
Table
(
"ExternalAuthenticators"
)
.
WithColumn
(
"Id"
).
AsGuid
().
PrimaryKey
().
WithDefault
(
SystemMethods
.
NewGuid
)
.
WithColumn
(
"Name"
).
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
(
"ExtrenalId"
).
AsString
(
255
);
Create
.
ForeignKey
()
.
FromTable
(
"ExternalIds"
).
ForeignColumn
(
"UserId"
)
.
ToTable
(
"Users"
).
PrimaryColumn
(
"Id"
);
Create
.
ForeignKey
()
.
FromTable
(
"ExternalIds"
).
ForeignColumn
(
"ResourceTypeId"
)
.
ToTable
(
"ExternalAuthenticators"
).
PrimaryColumn
(
"Id"
);
#
endregion
}
}
}
This diff is collapsed.
Click to expand it.
src/Migrator/Migrator.csproj
+
1
−
0
View file @
00bf9efb
...
@@ -145,6 +145,7 @@
...
@@ -145,6 +145,7 @@
<ItemGroup>
<ItemGroup>
<Compile
Include=
"Migrations\Migration201907011352ProjectApi.cs"
/>
<Compile
Include=
"Migrations\Migration201907011352ProjectApi.cs"
/>
<Compile
Include=
"Migrations\Migration201907081510EnhanceProjectApi.cs"
/>
<Compile
Include=
"Migrations\Migration201907081510EnhanceProjectApi.cs"
/>
<Compile
Include=
"Migrations\Migration201907100900UserProfilesApi.cs"
/>
<Compile
Include=
"Migrator.cs"
/>
<Compile
Include=
"Migrator.cs"
/>
<Compile
Include=
"Program.cs"
/>
<Compile
Include=
"Program.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
...
...
This diff is collapsed.
Click to expand it.
Ghost User
@ghost
mentioned in commit
a01a4365
·
6 years ago
mentioned in commit
a01a4365
mentioned in commit a01a43652c0ab3630f66d38e0452d311191b3e17
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment