mirror of
https://github.com/bitwarden/server.git
synced 2024-11-21 12:05:42 +01:00
[PM-5519] [PM-5526] [PM-5624] [PM-5600] Tweak EF settings for MySQL grant auto-increment (#3662)
* Tweak EF settings for grant auto-increment * Go back to zero generated default as that doesn't matter * Explicit value generation callout * Go with custom SQL for direct automatic increment * Proper column creation * Lint
This commit is contained in:
parent
23f9d2261d
commit
db4d7aa609
@ -12,6 +12,10 @@ public class GrantEntityTypeConfiguration : IEntityTypeConfiguration<Grant>
|
||||
.HasKey(s => s.Id)
|
||||
.IsClustered();
|
||||
|
||||
builder
|
||||
.Property(s => s.Id)
|
||||
.UseIdentityColumn();
|
||||
|
||||
builder
|
||||
.HasIndex(s => s.Key)
|
||||
.IsUnique(true);
|
||||
|
@ -1,6 +1,6 @@
|
||||
CREATE TABLE [dbo].[Grant]
|
||||
(
|
||||
[Id] INT NOT NULL IDENTITY,
|
||||
[Id] INT NOT NULL IDENTITY(1,1),
|
||||
[Key] NVARCHAR (200) NOT NULL,
|
||||
[Type] NVARCHAR (50) NOT NULL,
|
||||
[SubjectId] NVARCHAR (200) NULL,
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
@ -73,13 +72,7 @@ public partial class GrantIdWithIndexes : Migration
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "Id",
|
||||
table: "Grant",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);
|
||||
migrationBuilder.Sql("ALTER TABLE `Grant` ADD COLUMN `Id` INT AUTO_INCREMENT UNIQUE;");
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_Grant",
|
||||
|
@ -3,6 +3,7 @@ using System;
|
||||
using Bit.Infrastructure.EntityFramework.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
@ -488,7 +489,8 @@ namespace Bit.MySqlMigrations.Migrations
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("int")
|
||||
.HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);
|
||||
|
||||
b.Property<string>("ClientId")
|
||||
.IsRequired()
|
||||
|
@ -486,7 +486,8 @@ namespace Bit.SqliteMigrations.Migrations
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
.HasColumnType("INTEGER")
|
||||
.HasAnnotation("Sqlite:Autoincrement", true);
|
||||
|
||||
b.Property<string>("ClientId")
|
||||
.IsRequired()
|
||||
|
Loading…
Reference in New Issue
Block a user