提交 5cf3079b 编写于 作者: 麦壳饼's avatar 麦壳饼

1. 调整Mysql数据库的ef合并信息, 这意味着 Mysql 如果你在2022年安装过, 则需要手动升级或者全新安装并导入数据,

2. 删掉了Oracle12 的表结构信息重新添加。 这意味着过去的数据库结构不能再用, 你需要全新安装并导入旧数据。
3. 我们加入了 ef 删除最后一次 合并信息的 脚本。
上级 8d5df6b4
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace IoTSharp.Data.MySql.Migrations
{
public partial class add : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_DeviceIdentities_Device_DeviceId",
table: "DeviceIdentities");
migrationBuilder.DropIndex(
name: "IX_DeviceIdentities_DeviceId",
table: "DeviceIdentities");
migrationBuilder.AlterColumn<int>(
name: "Type",
table: "TelemetryData",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "int")
.Annotation("Relational:ColumnOrder", 5);
migrationBuilder.AlterColumn<int>(
name: "DataSide",
table: "TelemetryData",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "int")
.Annotation("Relational:ColumnOrder", 4);
migrationBuilder.AlterColumn<DateTime>(
name: "DateTime",
table: "TelemetryData",
type: "timestamp",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp")
.Annotation("Relational:ColumnOrder", 3);
migrationBuilder.AlterColumn<string>(
name: "KeyName",
table: "TelemetryData",
type: "varchar(255)",
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(255)")
.Annotation("MySql:CharSet", "utf8mb4")
.Annotation("Relational:ColumnOrder", 2)
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<Guid>(
name: "DeviceId",
table: "TelemetryData",
type: "char(36)",
nullable: false,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)")
.Annotation("Relational:ColumnOrder", 1)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn<Guid>(
name: "DeviceId",
table: "DeviceIdentities",
type: "char(36)",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn<int>(
name: "Type",
table: "DataStorage",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "int")
.Annotation("Relational:ColumnOrder", 5);
migrationBuilder.AlterColumn<DateTime>(
name: "DateTime",
table: "DataStorage",
type: "timestamp",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp")
.Annotation("Relational:ColumnOrder", 3);
migrationBuilder.AlterColumn<int>(
name: "DataSide",
table: "DataStorage",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "int")
.Annotation("Relational:ColumnOrder", 4);
migrationBuilder.AlterColumn<string>(
name: "KeyName",
table: "DataStorage",
type: "varchar(255)",
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(255)")
.Annotation("MySql:CharSet", "utf8mb4")
.Annotation("Relational:ColumnOrder", 2)
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<Guid>(
name: "DeviceId",
table: "DataStorage",
type: "char(36)",
nullable: false,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)")
.Annotation("Relational:ColumnOrder", 1)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn<int>(
name: "Catalog",
table: "DataStorage",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "int")
.Annotation("Relational:ColumnOrder", 0);
migrationBuilder.CreateIndex(
name: "IX_DeviceIdentities_DeviceId",
table: "DeviceIdentities",
column: "DeviceId",
unique: true);
migrationBuilder.AddForeignKey(
name: "FK_DeviceIdentities_Device_DeviceId",
table: "DeviceIdentities",
column: "DeviceId",
principalTable: "Device",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_DeviceIdentities_Device_DeviceId",
table: "DeviceIdentities");
migrationBuilder.DropIndex(
name: "IX_DeviceIdentities_DeviceId",
table: "DeviceIdentities");
migrationBuilder.AlterColumn<int>(
name: "Type",
table: "TelemetryData",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "int")
.OldAnnotation("Relational:ColumnOrder", 5);
migrationBuilder.AlterColumn<int>(
name: "DataSide",
table: "TelemetryData",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "int")
.OldAnnotation("Relational:ColumnOrder", 4);
migrationBuilder.AlterColumn<DateTime>(
name: "DateTime",
table: "TelemetryData",
type: "timestamp",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp")
.OldAnnotation("Relational:ColumnOrder", 3);
migrationBuilder.AlterColumn<string>(
name: "KeyName",
table: "TelemetryData",
type: "varchar(255)",
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(255)")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("Relational:ColumnOrder", 2);
migrationBuilder.AlterColumn<Guid>(
name: "DeviceId",
table: "TelemetryData",
type: "char(36)",
nullable: false,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)")
.OldAnnotation("Relational:Collation", "ascii_general_ci")
.OldAnnotation("Relational:ColumnOrder", 1);
migrationBuilder.AlterColumn<Guid>(
name: "DeviceId",
table: "DeviceIdentities",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn<int>(
name: "Type",
table: "DataStorage",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "int")
.OldAnnotation("Relational:ColumnOrder", 5);
migrationBuilder.AlterColumn<DateTime>(
name: "DateTime",
table: "DataStorage",
type: "timestamp",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp")
.OldAnnotation("Relational:ColumnOrder", 3);
migrationBuilder.AlterColumn<int>(
name: "DataSide",
table: "DataStorage",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "int")
.OldAnnotation("Relational:ColumnOrder", 4);
migrationBuilder.AlterColumn<string>(
name: "KeyName",
table: "DataStorage",
type: "varchar(255)",
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(255)")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("Relational:ColumnOrder", 2);
migrationBuilder.AlterColumn<Guid>(
name: "DeviceId",
table: "DataStorage",
type: "char(36)",
nullable: false,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)")
.OldAnnotation("Relational:Collation", "ascii_general_ci")
.OldAnnotation("Relational:ColumnOrder", 1);
migrationBuilder.AlterColumn<int>(
name: "Catalog",
table: "DataStorage",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "int")
.OldAnnotation("Relational:ColumnOrder", 0);
migrationBuilder.CreateIndex(
name: "IX_DeviceIdentities_DeviceId",
table: "DeviceIdentities",
column: "DeviceId");
migrationBuilder.AddForeignKey(
name: "FK_DeviceIdentities_Device_DeviceId",
table: "DeviceIdentities",
column: "DeviceId",
principalTable: "Device",
principalColumn: "Id");
}
}
}
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace IoTSharp.Data.MySql.Migrations
{
public partial class RefreshToken : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "RefreshTokens",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
UserId = table.Column<string>(type: "varchar(255)", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Token = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
JwtId = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
IsUsed = table.Column<bool>(type: "tinyint(1)", nullable: false),
IsRevorked = table.Column<bool>(type: "tinyint(1)", nullable: false),
AddedDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
ExpiryDate = table.Column<DateTime>(type: "datetime(6)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RefreshTokens", x => x.Id);
table.ForeignKey(
name: "FK_RefreshTokens_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id");
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_RefreshTokens_UserId",
table: "RefreshTokens",
column: "UserId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "RefreshTokens");
}
}
}
......@@ -11,14 +11,14 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace IoTSharp.Data.MySql.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20220210032430_RefreshToken")]
partial class RefreshToken
[Migration("20220211154512_AddTenantInfoAndRefToken")]
partial class AddTenantInfoAndRefToken
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.1")
.HasAnnotation("ProductVersion", "6.0.2")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("IoTSharp.Data.AuditLog", b =>
......
......@@ -4,7 +4,7 @@
namespace IoTSharp.Data.MySql.Migrations
{
public partial class addtelantinfo : Migration
public partial class AddTenantInfoAndRefToken : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
......
......@@ -16,7 +16,7 @@ namespace IoTSharp.Data.MySql.Migrations
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.1")
.HasAnnotation("ProductVersion", "6.0.2")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("IoTSharp.Data.AuditLog", b =>
......
......@@ -24,6 +24,7 @@ namespace IoTSharp.Data.Oracle
//https://docs.oracle.com/en/database/oracle/oracle-data-access-components/19.3.2/odpnt/EFCoreIdentifier.html#GUID-FA43F1A1-EDA2-462F-8844-45D49EF67607
//Setting maximum identifier length to 30 characters; By default, it's set to 128.
modelBuilder.Model.SetMaxIdentifierLength(30);
}
}
}
\ No newline at end of file
......@@ -35,6 +35,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{3048484A
buildimage.cmd = buildimage.cmd
tools\ef_db_drop.cmd = tools\ef_db_drop.cmd
tools\ef_mg_add.cmd = tools\ef_mg_add.cmd
tools\ef_mg_remove.cmd = tools\ef_mg_remove.cmd
tools\upgrade_ef.cmd = tools\upgrade_ef.cmd
EndProjectSection
EndProject
......
echo off
cls
echo remove a migration from IoTSharp.Data.%1
set ASPNETCORE_ENVIRONMENT=%1
dotnet ef migrations remove --context IoTSharp.Data.ApplicationDbContext --startup-project ..\IoTSharp\IoTSharp.csproj --project ..\IoTSharp.Data.%1\IoTSharp.Data.%1.csproj
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册