-
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
ff5d7c7
commit 32257bb
Showing
55 changed files
with
1,987 additions
and
44 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
75 changes: 75 additions & 0 deletions
75
src/EFCore/Orleans.Clustering.EntityFrameworkCore.SqlServer/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,75 @@ | ||
IF OBJECT_ID(N'[__EFMigrationsHistory]') IS NULL | ||
BEGIN | ||
CREATE TABLE [__EFMigrationsHistory] ( | ||
[MigrationId] nvarchar(150) NOT NULL, | ||
[ProductVersion] nvarchar(32) NOT NULL, | ||
CONSTRAINT [PK___EFMigrationsHistory] PRIMARY KEY ([MigrationId]) | ||
); | ||
END; | ||
GO | ||
|
||
BEGIN TRANSACTION; | ||
GO | ||
|
||
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20231005032242_InitialClusteringSchema') | ||
BEGIN | ||
CREATE TABLE [Clusters] ( | ||
[Id] nvarchar(450) NOT NULL, | ||
[Timestamp] datetimeoffset NOT NULL, | ||
[Version] int NOT NULL, | ||
[ETag] rowversion NOT NULL, | ||
CONSTRAINT [PK_Cluster] PRIMARY KEY NONCLUSTERED ([Id]) | ||
); | ||
END; | ||
GO | ||
|
||
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20231005032242_InitialClusteringSchema') | ||
BEGIN | ||
CREATE TABLE [Silos] ( | ||
[ClusterId] nvarchar(450) NOT NULL, | ||
[Address] nvarchar(45) NOT NULL, | ||
[Port] int NOT NULL, | ||
[Generation] int NOT NULL, | ||
[Name] nvarchar(150) NOT NULL, | ||
[HostName] nvarchar(150) NOT NULL, | ||
[Status] int NOT NULL, | ||
[ProxyPort] int NULL, | ||
[SuspectingTimes] nvarchar(max) NULL, | ||
[SuspectingSilos] nvarchar(max) NULL, | ||
[StartTime] datetimeoffset NOT NULL, | ||
[IAmAliveTime] datetimeoffset NOT NULL, | ||
[ETag] rowversion NOT NULL, | ||
CONSTRAINT [PK_Silo] PRIMARY KEY NONCLUSTERED ([ClusterId], [Address], [Port], [Generation]), | ||
CONSTRAINT [FK_Silos_Clusters_ClusterId] FOREIGN KEY ([ClusterId]) REFERENCES [Clusters] ([Id]) ON DELETE CASCADE | ||
); | ||
END; | ||
GO | ||
|
||
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20231005032242_InitialClusteringSchema') | ||
BEGIN | ||
CREATE NONCLUSTERED INDEX [IDX_Silo_ClusterId] ON [Silos] ([ClusterId]); | ||
END; | ||
GO | ||
|
||
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20231005032242_InitialClusteringSchema') | ||
BEGIN | ||
CREATE NONCLUSTERED INDEX [IDX_Silo_ClusterId_Status] ON [Silos] ([ClusterId], [Status]); | ||
END; | ||
GO | ||
|
||
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20231005032242_InitialClusteringSchema') | ||
BEGIN | ||
CREATE NONCLUSTERED INDEX [IDX_Silo_ClusterId_Status_IAmAlive] ON [Silos] ([ClusterId], [Status], [IAmAliveTime]); | ||
END; | ||
GO | ||
|
||
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20231005032242_InitialClusteringSchema') | ||
BEGIN | ||
INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion]) | ||
VALUES (N'20231005032242_InitialClusteringSchema', N'7.0.11'); | ||
END; | ||
GO | ||
|
||
COMMIT; | ||
GO | ||
|
143 changes: 143 additions & 0 deletions
143
...rameworkCore.SqlServer/Data/Migrations/20231005032242_InitialClusteringSchema.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
88 changes: 88 additions & 0 deletions
88
...g.EntityFrameworkCore.SqlServer/Data/Migrations/20231005032242_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,88 @@ | ||
using System; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
#nullable disable | ||
|
||
namespace Orleans.Clustering.EntityFrameworkCore.SqlServer.Data.Migrations | ||
{ | ||
/// <inheritdoc /> | ||
public partial class InitialClusteringSchema : Migration | ||
{ | ||
/// <inheritdoc /> | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.CreateTable( | ||
name: "Clusters", | ||
columns: table => new | ||
{ | ||
Id = table.Column<string>(type: "nvarchar(450)", nullable: false), | ||
Timestamp = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false), | ||
Version = table.Column<int>(type: "int", nullable: false), | ||
ETag = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_Cluster", x => x.Id) | ||
.Annotation("SqlServer:Clustered", false); | ||
}); | ||
|
||
migrationBuilder.CreateTable( | ||
name: "Silos", | ||
columns: table => new | ||
{ | ||
ClusterId = table.Column<string>(type: "nvarchar(450)", nullable: false), | ||
Address = table.Column<string>(type: "nvarchar(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: "nvarchar(150)", maxLength: 150, nullable: false), | ||
HostName = table.Column<string>(type: "nvarchar(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: "nvarchar(max)", nullable: true), | ||
SuspectingSilos = table.Column<string>(type: "nvarchar(max)", nullable: true), | ||
StartTime = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false), | ||
IAmAliveTime = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false), | ||
ETag = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_Silo", x => new { x.ClusterId, x.Address, x.Port, x.Generation }) | ||
.Annotation("SqlServer:Clustered", false); | ||
table.ForeignKey( | ||
name: "FK_Silos_Clusters_ClusterId", | ||
column: x => x.ClusterId, | ||
principalTable: "Clusters", | ||
principalColumn: "Id", | ||
onDelete: ReferentialAction.Cascade); | ||
}); | ||
|
||
migrationBuilder.CreateIndex( | ||
name: "IDX_Silo_ClusterId", | ||
table: "Silos", | ||
column: "ClusterId") | ||
.Annotation("SqlServer:Clustered", false); | ||
|
||
migrationBuilder.CreateIndex( | ||
name: "IDX_Silo_ClusterId_Status", | ||
table: "Silos", | ||
columns: new[] { "ClusterId", "Status" }) | ||
.Annotation("SqlServer:Clustered", false); | ||
|
||
migrationBuilder.CreateIndex( | ||
name: "IDX_Silo_ClusterId_Status_IAmAlive", | ||
table: "Silos", | ||
columns: new[] { "ClusterId", "Status", "IAmAliveTime" }) | ||
.Annotation("SqlServer:Clustered", false); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropTable( | ||
name: "Silos"); | ||
|
||
migrationBuilder.DropTable( | ||
name: "Clusters"); | ||
} | ||
} | ||
} |
Oops, something went wrong.