mirror of
https://github.com/bitwarden/server.git
synced 2024-12-05 14:23:30 +01:00
121 lines
3.4 KiB
C#
121 lines
3.4 KiB
C#
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||
|
|
|||
|
#nullable disable
|
|||
|
|
|||
|
namespace Bit.PostgresMigrations.Migrations;
|
|||
|
|
|||
|
/// <inheritdoc />
|
|||
|
public partial class GrantIdWithIndexes : Migration
|
|||
|
{
|
|||
|
/// <inheritdoc />
|
|||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.DropPrimaryKey(
|
|||
|
name: "PK_Grant",
|
|||
|
table: "Grant");
|
|||
|
|
|||
|
migrationBuilder.AlterColumn<string>(
|
|||
|
name: "Type",
|
|||
|
table: "Grant",
|
|||
|
type: "character varying(50)",
|
|||
|
maxLength: 50,
|
|||
|
nullable: false,
|
|||
|
defaultValue: "",
|
|||
|
oldClrType: typeof(string),
|
|||
|
oldType: "character varying(50)",
|
|||
|
oldMaxLength: 50,
|
|||
|
oldNullable: true);
|
|||
|
|
|||
|
migrationBuilder.AlterColumn<string>(
|
|||
|
name: "Data",
|
|||
|
table: "Grant",
|
|||
|
type: "text",
|
|||
|
nullable: false,
|
|||
|
defaultValue: "",
|
|||
|
oldClrType: typeof(string),
|
|||
|
oldType: "text",
|
|||
|
oldNullable: true);
|
|||
|
|
|||
|
migrationBuilder.AlterColumn<string>(
|
|||
|
name: "ClientId",
|
|||
|
table: "Grant",
|
|||
|
type: "character varying(200)",
|
|||
|
maxLength: 200,
|
|||
|
nullable: false,
|
|||
|
defaultValue: "",
|
|||
|
oldClrType: typeof(string),
|
|||
|
oldType: "character varying(200)",
|
|||
|
oldMaxLength: 200,
|
|||
|
oldNullable: true);
|
|||
|
|
|||
|
migrationBuilder.AddColumn<int>(
|
|||
|
name: "Id",
|
|||
|
table: "Grant",
|
|||
|
type: "integer",
|
|||
|
nullable: false,
|
|||
|
defaultValue: 0)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|||
|
|
|||
|
migrationBuilder.AddPrimaryKey(
|
|||
|
name: "PK_Grant",
|
|||
|
table: "Grant",
|
|||
|
column: "Id");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Grant_Key",
|
|||
|
table: "Grant",
|
|||
|
column: "Key",
|
|||
|
unique: true);
|
|||
|
}
|
|||
|
|
|||
|
/// <inheritdoc />
|
|||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.DropPrimaryKey(
|
|||
|
name: "PK_Grant",
|
|||
|
table: "Grant");
|
|||
|
|
|||
|
migrationBuilder.DropIndex(
|
|||
|
name: "IX_Grant_Key",
|
|||
|
table: "Grant");
|
|||
|
|
|||
|
migrationBuilder.DropColumn(
|
|||
|
name: "Id",
|
|||
|
table: "Grant");
|
|||
|
|
|||
|
migrationBuilder.AlterColumn<string>(
|
|||
|
name: "Type",
|
|||
|
table: "Grant",
|
|||
|
type: "character varying(50)",
|
|||
|
maxLength: 50,
|
|||
|
nullable: true,
|
|||
|
oldClrType: typeof(string),
|
|||
|
oldType: "character varying(50)",
|
|||
|
oldMaxLength: 50);
|
|||
|
|
|||
|
migrationBuilder.AlterColumn<string>(
|
|||
|
name: "Data",
|
|||
|
table: "Grant",
|
|||
|
type: "text",
|
|||
|
nullable: true,
|
|||
|
oldClrType: typeof(string),
|
|||
|
oldType: "text");
|
|||
|
|
|||
|
migrationBuilder.AlterColumn<string>(
|
|||
|
name: "ClientId",
|
|||
|
table: "Grant",
|
|||
|
type: "character varying(200)",
|
|||
|
maxLength: 200,
|
|||
|
nullable: true,
|
|||
|
oldClrType: typeof(string),
|
|||
|
oldType: "character varying(200)",
|
|||
|
oldMaxLength: 200);
|
|||
|
|
|||
|
migrationBuilder.AddPrimaryKey(
|
|||
|
name: "PK_Grant",
|
|||
|
table: "Grant",
|
|||
|
column: "Key");
|
|||
|
}
|
|||
|
}
|