29 lines
1.2 KiB
C#
29 lines
1.2 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using System;
|
|
|
|
#nullable disable
|
|
|
|
namespace gehGassi.Persistence.Migrations
|
|
{
|
|
public partial class vw_DogWalkers : Migration
|
|
{
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
var viewName = "vw_DogWalkers";
|
|
var sql = @"Select AU.*, DP.Radius, DP.About, DP.AllowedRequests, DP.PuppyAllowed, DP.DifficultAllowed, DP.AggressionLevel, DP.AcceptedSize, DP.PriceWalk, DP.PriceDay, DP.PriceSitting
|
|
from AppUsers AU
|
|
JOIN DogWalkerProfiles DP ON DP.Id = AU.Id
|
|
WHERE AU.Type != 10";
|
|
|
|
migrationBuilder.Sql($"IF(exists (SELECT 1 FROM sys.views WHERE Name = '{viewName}')) BEGIN DROP VIEW [dbo].[{viewName}] END {Environment.NewLine} GO");
|
|
migrationBuilder.Sql($"CREATE VIEW [dbo].[{viewName}] AS {sql} {Environment.NewLine} GO");
|
|
}
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
var viewName = "vw_DogWalkers";
|
|
migrationBuilder.Sql($"IF(exists (SELECT 1 FROM sys.views WHERE Name = '{viewName}')) BEGIN DROP VIEW [dbo].[{viewName}] END {Environment.NewLine} GO");
|
|
}
|
|
}
|
|
}
|