-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
32257bb
commit 659aa2b
Showing
67 changed files
with
2,327 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/EFCore/Orleans.Clustering.EntityFrameworkCore.MySql/Clustering.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
CREATE TABLE IF NOT EXISTS `__EFMigrationsHistory` ( | ||
`MigrationId` varchar(150) NOT NULL, | ||
`ProductVersion` varchar(32) NOT NULL, | ||
PRIMARY KEY (`MigrationId`) | ||
); | ||
|
||
START TRANSACTION; | ||
|
||
IF NOT EXISTS(SELECT * FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20231007024046_InitialClusteringSchema') | ||
BEGIN | ||
CREATE TABLE `Clusters` ( | ||
`Id` varchar(255) NOT NULL, | ||
`Timestamp` datetime(6) NOT NULL, | ||
`Version` int NOT NULL, | ||
`ETag` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), | ||
PRIMARY KEY (`Id`) | ||
); | ||
END; | ||
|
||
IF NOT EXISTS(SELECT * FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20231007024046_InitialClusteringSchema') | ||
BEGIN | ||
CREATE TABLE `Silos` ( | ||
`ClusterId` varchar(255) NOT NULL, | ||
`Address` varchar(45) NOT NULL, | ||
`Port` int NOT NULL, | ||
`Generation` int NOT NULL, | ||
`Name` varchar(150) NOT NULL, | ||
`HostName` varchar(150) NOT NULL, | ||
`Status` int NOT NULL, | ||
`ProxyPort` int NULL, | ||
`SuspectingTimes` longtext NULL, | ||
`SuspectingSilos` longtext NULL, | ||
`StartTime` datetime(6) NOT NULL, | ||
`IAmAliveTime` datetime(6) NOT NULL, | ||
`ETag` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), | ||
PRIMARY KEY (`ClusterId`, `Address`, `Port`, `Generation`), | ||
CONSTRAINT `FK_Silos_Clusters_ClusterId` FOREIGN KEY (`ClusterId`) REFERENCES `Clusters` (`Id`) ON DELETE CASCADE | ||
); | ||
END; | ||
|
||
IF NOT EXISTS(SELECT * FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20231007024046_InitialClusteringSchema') | ||
BEGIN | ||
CREATE INDEX `IDX_Silo_ClusterId` ON `Silos` (`ClusterId`); | ||
END; | ||
|
||
IF NOT EXISTS(SELECT * FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20231007024046_InitialClusteringSchema') | ||
BEGIN | ||
CREATE INDEX `IDX_Silo_ClusterId_Status` ON `Silos` (`ClusterId`, `Status`); | ||
END; | ||
|
||
IF NOT EXISTS(SELECT * FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20231007024046_InitialClusteringSchema') | ||
BEGIN | ||
CREATE INDEX `IDX_Silo_ClusterId_Status_IAmAlive` ON `Silos` (`ClusterId`, `Status`, `IAmAliveTime`); | ||
END; | ||
|
||
IF NOT EXISTS(SELECT * FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20231007024046_InitialClusteringSchema') | ||
BEGIN | ||
INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) | ||
VALUES ('20231007024046_InitialClusteringSchema', '7.0.11'); | ||
END; | ||
|
||
COMMIT; | ||
|
128 changes: 128 additions & 0 deletions
128
...ityFrameworkCore.MySql/Data/Migrations/20231007024046_InitialClusteringSchema.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
91 changes: 91 additions & 0 deletions
91
...ering.EntityFrameworkCore.MySql/Data/Migrations/20231007024046_InitialClusteringSchema.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
using System; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
using MySql.EntityFrameworkCore.Metadata; | ||
|
||
#nullable disable | ||
|
||
namespace Orleans.Clustering.EntityFrameworkCore.MySql.Data.Migrations | ||
{ | ||
/// <inheritdoc /> | ||
public partial class InitialClusteringSchema : Migration | ||
{ | ||
/// <inheritdoc /> | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.AlterDatabase() | ||
.Annotation("MySQL:Charset", "utf8mb4"); | ||
|
||
migrationBuilder.CreateTable( | ||
name: "Clusters", | ||
columns: table => new | ||
{ | ||
Id = table.Column<string>(type: "varchar(255)", nullable: false), | ||
Timestamp = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: false), | ||
Version = table.Column<int>(type: "int", nullable: false), | ||
ETag = table.Column<DateTime>(type: "datetime(6)", rowVersion: true, nullable: false) | ||
.Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.ComputedColumn) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_Cluster", x => x.Id); | ||
}) | ||
.Annotation("MySQL:Charset", "utf8mb4"); | ||
|
||
migrationBuilder.CreateTable( | ||
name: "Silos", | ||
columns: table => new | ||
{ | ||
ClusterId = table.Column<string>(type: "varchar(255)", nullable: false), | ||
Address = table.Column<string>(type: "varchar(45)", maxLength: 45, nullable: false), | ||
Port = table.Column<int>(type: "int", nullable: false), | ||
Generation = table.Column<int>(type: "int", nullable: false), | ||
Name = table.Column<string>(type: "varchar(150)", maxLength: 150, nullable: false), | ||
HostName = table.Column<string>(type: "varchar(150)", maxLength: 150, nullable: false), | ||
Status = table.Column<int>(type: "int", nullable: false), | ||
ProxyPort = table.Column<int>(type: "int", nullable: true), | ||
SuspectingTimes = table.Column<string>(type: "longtext", nullable: true), | ||
SuspectingSilos = table.Column<string>(type: "longtext", nullable: true), | ||
StartTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: false), | ||
IAmAliveTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: false), | ||
ETag = table.Column<DateTime>(type: "datetime(6)", rowVersion: true, nullable: false) | ||
.Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.ComputedColumn) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_Silo", x => new { x.ClusterId, x.Address, x.Port, x.Generation }); | ||
table.ForeignKey( | ||
name: "FK_Silos_Clusters_ClusterId", | ||
column: x => x.ClusterId, | ||
principalTable: "Clusters", | ||
principalColumn: "Id", | ||
onDelete: ReferentialAction.Cascade); | ||
}) | ||
.Annotation("MySQL:Charset", "utf8mb4"); | ||
|
||
migrationBuilder.CreateIndex( | ||
name: "IDX_Silo_ClusterId", | ||
table: "Silos", | ||
column: "ClusterId"); | ||
|
||
migrationBuilder.CreateIndex( | ||
name: "IDX_Silo_ClusterId_Status", | ||
table: "Silos", | ||
columns: new[] { "ClusterId", "Status" }); | ||
|
||
migrationBuilder.CreateIndex( | ||
name: "IDX_Silo_ClusterId_Status_IAmAlive", | ||
table: "Silos", | ||
columns: new[] { "ClusterId", "Status", "IAmAliveTime" }); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropTable( | ||
name: "Silos"); | ||
|
||
migrationBuilder.DropTable( | ||
name: "Clusters"); | ||
} | ||
} | ||
} |
Oops, something went wrong.