Commit a579f181 authored by Robert Rudman's avatar Robert Rudman

Fix migration error

parent 779428ab
Pipeline #49222777 canceled with stages
in 0 seconds
......@@ -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
);
");
}
}
}
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