Small changes to the DB migration

This commit is contained in:
tidusjar 2020-04-29 22:19:17 +01:00
commit d7cdf68a86
2 changed files with 43 additions and 13 deletions

View file

@ -1,6 +1,6 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using System;
namespace Ombi.Store.Migrations.OmbiMySql
{
@ -8,15 +8,35 @@ namespace Ombi.Store.Migrations.OmbiMySql
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(@"CREATE TABLE `MobileDevices` (
`Id` int NOT NULL AUTO_INCREMENT,
`Token` longtext CHARACTER SET utf8mb4 NULL,
`UserId` varchar(255) COLLATE utf8mb4_bin NOT NULL,
`AddedAt` datetime(6) NOT NULL,
CONSTRAINT `PK_MobileDevices` PRIMARY KEY (`Id`),
CONSTRAINT `FK_MobileDevices_AspNetUsers_UserId` FOREIGN KEY (`UserId`) REFERENCES `AspNetUsers` (`Id`) ON DELETE RESTRICT
);");
// migrationBuilder.Sql(@"CREATE TABLE `MobileDevices` (
// `Id` int NOT NULL AUTO_INCREMENT,
// `Token` longtext CHARACTER SET utf8mb4 NULL,
// `UserId` varchar(255) COLLATE utf8mb4_bin NOT NULL,
// `AddedAt` datetime(6) NOT NULL,
// CONSTRAINT `PK_MobileDevices` PRIMARY KEY (`Id`),
// CONSTRAINT `FK_MobileDevices_AspNetUsers_UserId` FOREIGN KEY (`UserId`) REFERENCES `AspNetUsers` (`Id`) ON DELETE RESTRICT
//);");
migrationBuilder.CreateTable(
name: "MobileDevices",
columns: table => new
{
Id = table.Column<int>(nullable: false).Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Token = table.Column<string>(maxLength: 256, nullable: true),
UserId = table.Column<string>(maxLength: 256, nullable: false),
AddedAt = table.Column<DateTime>(maxLength: 256, nullable: false),
},
constraints: table =>
{
table.PrimaryKey("PK_MobileDevices", x => x.Id);
table.ForeignKey(
name: "FK_MobileDevices_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_MobileDevices_UserId",