btcpayserver/BTCPayServer.Data/Migrations/20230504125505_StoreRoles.cs

91 lines
3.4 KiB
C#
Raw Normal View History

2023-05-26 16:49:32 +02:00
using System;
using BTCPayServer.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using NBitcoin;
using Newtonsoft.Json;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace BTCPayServer.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20230504125505_StoreRoles")]
public partial class StoreRoles : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "StoreRoles",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", nullable: false),
StoreDataId = table.Column<string>(type: "TEXT", nullable: true),
Role = table.Column<string>(type: "TEXT", nullable: false),
2024-04-15 19:08:25 +09:00
Permissions = table.Column<string>(type: "TEXT[]", nullable: false)
2023-05-26 16:49:32 +02:00
},
constraints: table =>
{
table.PrimaryKey("PK_StoreRoles", x => x.Id);
table.ForeignKey(
name: "FK_StoreRoles_Stores_StoreDataId",
column: x => x.StoreDataId,
principalTable: "Stores",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_StoreRoles_StoreDataId_Role",
table: "StoreRoles",
columns: new[] { "StoreDataId", "Role" },
unique: true);
migrationBuilder.InsertData(
"StoreRoles",
columns: new[] { "Id", "Role", "Permissions" },
2024-04-15 19:08:25 +09:00
columnTypes: new[] { "TEXT", "TEXT", "TEXT[]" },
2023-05-26 16:49:32 +02:00
values: new object[,]
{
{
2024-04-15 19:08:25 +09:00
"Owner", "Owner", new[]
2023-05-26 16:49:32 +02:00
{
"btcpay.store.canmodifystoresettings",
"btcpay.store.cantradecustodianaccount",
"btcpay.store.canwithdrawfromcustodianaccount",
"btcpay.store.candeposittocustodianaccount"
2024-04-15 19:08:25 +09:00
}
2023-05-26 16:49:32 +02:00
},
{
2024-04-15 19:08:25 +09:00
"Guest", "Guest", new[]
2023-05-26 16:49:32 +02:00
{
"btcpay.store.canviewstoresettings",
"btcpay.store.canmodifyinvoices",
"btcpay.store.canviewcustodianaccounts",
"btcpay.store.candeposittocustodianaccount"
2024-04-15 19:08:25 +09:00
}
2023-05-26 16:49:32 +02:00
}
});
2024-04-15 19:08:25 +09:00
migrationBuilder.AddForeignKey(
name: "FK_UserStore_StoreRoles_Role",
table: "UserStore",
column: "Role",
principalTable: "StoreRoles",
principalColumn: "Id");
2023-05-26 16:49:32 +02:00
}
protected override void Down(MigrationBuilder migrationBuilder)
{
2024-04-15 19:08:25 +09:00
migrationBuilder.DropForeignKey(
name: "FK_UserStore_StoreRoles_Role",
table: "UserStore");
2023-05-26 16:49:32 +02:00
migrationBuilder.DropTable(
name: "StoreRoles");
}
}
}