Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
R
Rodgort
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Robert Rudman
Rodgort
Commits
a579f181
Commit
a579f181
authored
Feb 26, 2019
by
Robert Rudman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix migration error
parent
779428ab
Pipeline
#49222777
canceled with stages
in 0 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
0 deletions
+54
-0
Rodgort/Migrations/20190226052847_RemoveDefaultValueForIsSynonym.cs
...grations/20190226052847_RemoveDefaultValueForIsSynonym.cs
+54
-0
No files found.
Rodgort/Migrations/20190226052847_RemoveDefaultValueForIsSynonym.cs
View file @
a579f181
...
...
@@ -6,22 +6,76 @@ namespace Rodgort.Migrations
{
protected
override
void
Up
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
Sql
(
@"
DROP MATERIALIZED VIEW zombie_tags;
"
);
migrationBuilder
.
AlterColumn
<
bool
>(
name
:
"is_synonym"
,
table
:
"tag_statistics"
,
nullable
:
false
,
oldClrType
:
typeof
(
bool
),
oldDefaultValue
:
false
);
migrationBuilder
.
Sql
(
@"
CREATE MATERIALIZED VIEW zombie_tags as (
select
tag_name as tag_name,
date_time time_revived
from (
select
ts.tag_name,
ts.date_time,
case
when lag(question_count) over (partition by ts.tag_name order by ts.date_time) = 0
and not lag(is_synonym) over (partition by ts.tag_name order by ts.date_time)
and question_count > 0 then true
else false
end
as revived
from tag_statistics ts
inner join meta_question_tags mqt on mqt.tag_name = ts.tag_name and mqt.tracking_status_id = 2
) innerQuery
where innerQuery.revived
);
"
);
}
protected
override
void
Down
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
Sql
(
@"
DROP MATERIALIZED VIEW zombie_tags;
"
);
migrationBuilder
.
AlterColumn
<
bool
>(
name
:
"is_synonym"
,
table
:
"tag_statistics"
,
nullable
:
false
,
defaultValue
:
false
,
oldClrType
:
typeof
(
bool
));
migrationBuilder
.
Sql
(
@"
CREATE MATERIALIZED VIEW zombie_tags as (
select
tag_name as tag_name,
date_time time_revived
from (
select
ts.tag_name,
ts.date_time,
case
when lag(question_count) over (partition by ts.tag_name order by ts.date_time) = 0
and not lag(is_synonym) over (partition by ts.tag_name order by ts.date_time)
and question_count > 0 then true
else false
end
as revived
from tag_statistics ts
inner join meta_question_tags mqt on mqt.tag_name = ts.tag_name and mqt.tracking_status_id = 2
) innerQuery
where innerQuery.revived
);
"
);
}
}
}
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