btcpayserver/BTCPayServer.Data/Migrations/20200119130108_ExtendApiKeys.cs
Andrew Camilleri fa51180dfa
Api keys with openiddict (#1262)
* Remove OpenIddict

* Add API Key system

* Revert removing OpenIddict

* fix rebase

* fix tests

* pr changes

* fix tests

* fix apikey test

* pr change

* fix db

* add migration attrs

* fix migration error

* PR Changes

* Fix sqlite migration

* change api key to use Authorization Header

* add supportAddForeignKey

* use tempdata status message

* fix add api key css

* remove redirect url + app identifier feature :(
2020-02-24 22:36:15 +09:00

74 lines
2.4 KiB
C#

using BTCPayServer.Data;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
namespace BTCPayServer.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20200119130108_ExtendApiKeys")]
public partial class ExtendApiKeys : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Permissions",
table: "ApiKeys",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "Type",
table: "ApiKeys",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<string>(
name: "UserId",
table: "ApiKeys",
maxLength: 50,
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_ApiKeys_UserId",
table: "ApiKeys",
column: "UserId");
if (this.SupportAddForeignKey(migrationBuilder.ActiveProvider))
{
migrationBuilder.AddForeignKey(
name: "FK_ApiKeys_AspNetUsers_UserId",
table: "ApiKeys",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
protected override void Down(MigrationBuilder migrationBuilder)
{
if (this.SupportDropForeignKey(migrationBuilder.ActiveProvider))
{
migrationBuilder.DropForeignKey(
name: "FK_ApiKeys_AspNetUsers_UserId",
table: "ApiKeys");
}
migrationBuilder.DropIndex(
name: "IX_ApiKeys_UserId",
table: "ApiKeys");
if (this.SupportDropColumn(migrationBuilder.ActiveProvider))
{
migrationBuilder.DropColumn(
name: "Permissions",
table: "ApiKeys");
migrationBuilder.DropColumn(
name: "Type",
table: "ApiKeys");
migrationBuilder.DropColumn(
name: "UserId",
table: "ApiKeys");
}
}
}
}