using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace gehGassi.Persistence.Migrations
{
///
public partial class DogWalkerPrivacyAdded : 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, DP.NotAvailable, DP.NotAvailableInfo
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";
var sql = @"Select AU.*, DP.Radius, DP.About, DP.AllowedRequests, DP.PuppyAllowed, DP.DifficultAllowed, DP.AggressionLevel, DP.AcceptedSize, DP.PriceWalk, DP.PriceDay, DP.PriceSitting, DP.NotAvailable, DP.NotAvailableInfo
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");
}
}
}