Browse Source
* Add SQL files * Add SQL Server migration * Add Core entity * Add Dapper repository * Add EF repository * Add EF migrations * Save OrganizationInstallation during GetLicense invocation * Run dotnet formatpull/5014/head
28 changed files with 9751 additions and 2 deletions
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
using Bit.Core.Entities; |
||||
using Bit.Core.Utilities; |
||||
|
||||
namespace Bit.Core.Billing.Entities; |
||||
|
||||
#nullable enable |
||||
|
||||
public class OrganizationInstallation : ITableObject<Guid> |
||||
{ |
||||
public Guid Id { get; set; } |
||||
|
||||
public Guid OrganizationId { get; set; } |
||||
public Guid InstallationId { get; set; } |
||||
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow; |
||||
public DateTime? RevisionDate { get; set; } |
||||
|
||||
public void SetNewId() |
||||
{ |
||||
if (Id == default) |
||||
{ |
||||
Id = CoreHelpers.GenerateComb(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,10 @@
@@ -0,0 +1,10 @@
|
||||
using Bit.Core.Billing.Entities; |
||||
using Bit.Core.Repositories; |
||||
|
||||
namespace Bit.Core.Billing.Repositories; |
||||
|
||||
public interface IOrganizationInstallationRepository : IRepository<OrganizationInstallation, Guid> |
||||
{ |
||||
Task<OrganizationInstallation> GetByInstallationIdAsync(Guid installationId); |
||||
Task<ICollection<OrganizationInstallation>> GetByOrganizationIdAsync(Guid organizationId); |
||||
} |
||||
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
using System.Data; |
||||
using Bit.Core.Billing.Entities; |
||||
using Bit.Core.Billing.Repositories; |
||||
using Bit.Core.Settings; |
||||
using Bit.Infrastructure.Dapper.Repositories; |
||||
using Dapper; |
||||
using Microsoft.Data.SqlClient; |
||||
|
||||
namespace Bit.Infrastructure.Dapper.Billing.Repositories; |
||||
|
||||
public class OrganizationInstallationRepository( |
||||
GlobalSettings globalSettings) : Repository<OrganizationInstallation, Guid>( |
||||
globalSettings.SqlServer.ConnectionString, |
||||
globalSettings.SqlServer.ReadOnlyConnectionString), IOrganizationInstallationRepository |
||||
{ |
||||
public async Task<OrganizationInstallation> GetByInstallationIdAsync(Guid installationId) |
||||
{ |
||||
var sqlConnection = new SqlConnection(ConnectionString); |
||||
|
||||
var results = await sqlConnection.QueryAsync<OrganizationInstallation>( |
||||
"[dbo].[OrganizationInstallation_ReadByInstallationId]", |
||||
new { InstallationId = installationId }, |
||||
commandType: CommandType.StoredProcedure); |
||||
|
||||
return results.FirstOrDefault(); |
||||
} |
||||
|
||||
public async Task<ICollection<OrganizationInstallation>> GetByOrganizationIdAsync(Guid organizationId) |
||||
{ |
||||
var sqlConnection = new SqlConnection(ConnectionString); |
||||
|
||||
var results = await sqlConnection.QueryAsync<OrganizationInstallation>( |
||||
"[dbo].[OrganizationInstallation_ReadByOrganizationId]", |
||||
new { OrganizationId = organizationId }, |
||||
commandType: CommandType.StoredProcedure); |
||||
|
||||
return results.ToArray(); |
||||
} |
||||
} |
||||
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
using Bit.Infrastructure.EntityFramework.Billing.Models; |
||||
using Microsoft.EntityFrameworkCore; |
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders; |
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Billing.Configurations; |
||||
|
||||
public class OrganizationInstallationEntityTypeConfiguration : IEntityTypeConfiguration<OrganizationInstallation> |
||||
{ |
||||
public void Configure(EntityTypeBuilder<OrganizationInstallation> builder) |
||||
{ |
||||
builder |
||||
.Property(oi => oi.Id) |
||||
.ValueGeneratedNever(); |
||||
|
||||
builder |
||||
.HasKey(oi => oi.Id) |
||||
.IsClustered(); |
||||
|
||||
builder |
||||
.HasIndex(oi => oi.OrganizationId) |
||||
.IsClustered(false); |
||||
|
||||
builder |
||||
.HasIndex(oi => oi.InstallationId) |
||||
.IsClustered(false); |
||||
|
||||
builder.ToTable(nameof(OrganizationInstallation)); |
||||
} |
||||
} |
||||
@ -0,0 +1,19 @@
@@ -0,0 +1,19 @@
|
||||
using AutoMapper; |
||||
using Bit.Infrastructure.EntityFramework.AdminConsole.Models; |
||||
using Bit.Infrastructure.EntityFramework.Models; |
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Billing.Models; |
||||
|
||||
public class OrganizationInstallation : Core.Billing.Entities.OrganizationInstallation |
||||
{ |
||||
public virtual Installation Installation { get; set; } |
||||
public virtual Organization Organization { get; set; } |
||||
} |
||||
|
||||
public class OrganizationInstallationMapperProfile : Profile |
||||
{ |
||||
public OrganizationInstallationMapperProfile() |
||||
{ |
||||
CreateMap<Core.Billing.Entities.OrganizationInstallation, OrganizationInstallation>().ReverseMap(); |
||||
} |
||||
} |
||||
@ -0,0 +1,45 @@
@@ -0,0 +1,45 @@
|
||||
using AutoMapper; |
||||
using Bit.Core.Billing.Entities; |
||||
using Bit.Core.Billing.Repositories; |
||||
using Bit.Infrastructure.EntityFramework.Repositories; |
||||
using Microsoft.EntityFrameworkCore; |
||||
using Microsoft.Extensions.DependencyInjection; |
||||
using EFOrganizationInstallation = Bit.Infrastructure.EntityFramework.Billing.Models.OrganizationInstallation; |
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Billing.Repositories; |
||||
|
||||
public class OrganizationInstallationRepository( |
||||
IMapper mapper, |
||||
IServiceScopeFactory serviceScopeFactory) : Repository<OrganizationInstallation, EFOrganizationInstallation, Guid>( |
||||
serviceScopeFactory, |
||||
mapper, |
||||
context => context.OrganizationInstallations), IOrganizationInstallationRepository |
||||
{ |
||||
public async Task<OrganizationInstallation> GetByInstallationIdAsync(Guid installationId) |
||||
{ |
||||
using var serviceScope = ServiceScopeFactory.CreateScope(); |
||||
|
||||
var databaseContext = GetDatabaseContext(serviceScope); |
||||
|
||||
var query = |
||||
from organizationInstallation in databaseContext.OrganizationInstallations |
||||
where organizationInstallation.Id == installationId |
||||
select organizationInstallation; |
||||
|
||||
return await query.FirstOrDefaultAsync(); |
||||
} |
||||
|
||||
public async Task<ICollection<OrganizationInstallation>> GetByOrganizationIdAsync(Guid organizationId) |
||||
{ |
||||
using var serviceScope = ServiceScopeFactory.CreateScope(); |
||||
|
||||
var databaseContext = GetDatabaseContext(serviceScope); |
||||
|
||||
var query = |
||||
from organizationInstallation in databaseContext.OrganizationInstallations |
||||
where organizationInstallation.OrganizationId == organizationId |
||||
select organizationInstallation; |
||||
|
||||
return await query.ToArrayAsync(); |
||||
} |
||||
} |
||||
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
CREATE PROCEDURE [dbo].[OrganizationInstallation_Create] |
||||
@Id UNIQUEIDENTIFIER OUTPUT, |
||||
@OrganizationId UNIQUEIDENTIFIER, |
||||
@InstallationId UNIQUEIDENTIFIER, |
||||
@CreationDate DATETIME2 (7), |
||||
@RevisionDate DATETIME2 (7) = NULL |
||||
AS |
||||
BEGIN |
||||
SET NOCOUNT ON |
||||
|
||||
INSERT INTO [dbo].[OrganizationInstallation] |
||||
( |
||||
[Id], |
||||
[OrganizationId], |
||||
[InstallationId], |
||||
[CreationDate], |
||||
[RevisionDate] |
||||
) |
||||
VALUES |
||||
( |
||||
@Id, |
||||
@OrganizationId, |
||||
@InstallationId, |
||||
@CreationDate, |
||||
@RevisionDate |
||||
) |
||||
END |
||||
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
CREATE PROCEDURE [dbo].[OrganizationInstallation_DeleteById] |
||||
@Id UNIQUEIDENTIFIER |
||||
AS |
||||
BEGIN |
||||
SET NOCOUNT ON |
||||
|
||||
DELETE |
||||
FROM |
||||
[dbo].[OrganizationInstallation] |
||||
WHERE |
||||
[Id] = @Id |
||||
END |
||||
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
CREATE PROCEDURE [dbo].[OrganizationInstallation_ReadById] |
||||
@Id UNIQUEIDENTIFIER |
||||
AS |
||||
BEGIN |
||||
SET NOCOUNT ON |
||||
|
||||
SELECT |
||||
* |
||||
FROM |
||||
[dbo].[OrganizationInstallationView] |
||||
WHERE |
||||
[Id] = @Id |
||||
END |
||||
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
CREATE PROCEDURE [dbo].[OrganizationInstallation_ReadByInstallationId] |
||||
@InstallationId UNIQUEIDENTIFIER |
||||
AS |
||||
BEGIN |
||||
SET NOCOUNT ON |
||||
|
||||
SELECT |
||||
* |
||||
FROM |
||||
[dbo].[OrganizationInstallationView] |
||||
WHERE |
||||
[InstallationId] = @InstallationId |
||||
END |
||||
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
CREATE PROCEDURE [dbo].[OrganizationInstallation_ReadByOrganizationId] |
||||
@OrganizationId UNIQUEIDENTIFIER |
||||
AS |
||||
BEGIN |
||||
SET NOCOUNT ON |
||||
|
||||
SELECT |
||||
* |
||||
FROM |
||||
[dbo].[OrganizationInstallationView] |
||||
WHERE |
||||
[OrganizationId] = @OrganizationId |
||||
END |
||||
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
CREATE PROCEDURE [dbo].[OrganizationInstallation_Update] |
||||
@Id UNIQUEIDENTIFIER OUTPUT, |
||||
@OrganizationId UNIQUEIDENTIFIER, |
||||
@InstallationId UNIQUEIDENTIFIER, |
||||
@CreationDate DATETIME2 (7), |
||||
@RevisionDate DATETIME2 (7) |
||||
AS |
||||
BEGIN |
||||
SET NOCOUNT ON |
||||
|
||||
UPDATE |
||||
[dbo].[OrganizationInstallation] |
||||
SET |
||||
[RevisionDate] = @RevisionDate |
||||
WHERE |
||||
[Id] = @Id |
||||
END |
||||
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
CREATE TABLE [dbo].[OrganizationInstallation] ( |
||||
[Id] UNIQUEIDENTIFIER NOT NULL, |
||||
[OrganizationId] UNIQUEIDENTIFIER NOT NULL, |
||||
[InstallationId] UNIQUEIDENTIFIER NOT NULL, |
||||
[CreationDate] DATETIME2 (7) NOT NULL, |
||||
[RevisionDate] DATETIME2 (7) NULL, |
||||
CONSTRAINT [PK_OrganizationInstallation] PRIMARY KEY CLUSTERED ([Id] ASC), |
||||
CONSTRAINT [FK_OrganizationInstallation_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id]) ON DELETE CASCADE, |
||||
CONSTRAINT [FK_OrganizationInstallation_Installation] FOREIGN KEY ([InstallationId]) REFERENCES [dbo].[Installation] ([Id]) ON DELETE CASCADE |
||||
); |
||||
GO |
||||
|
||||
CREATE NONCLUSTERED INDEX [IX_OrganizationInstallation_OrganizationId] |
||||
ON [dbo].[OrganizationInstallation]([OrganizationId] ASC); |
||||
GO |
||||
|
||||
CREATE NONCLUSTERED INDEX [IX_OrganizationInstallation_InstallationId] |
||||
ON [dbo].[OrganizationInstallation]([InstallationId] ASC); |
||||
@ -0,0 +1,6 @@
@@ -0,0 +1,6 @@
|
||||
CREATE VIEW [dbo].[OrganizationInstallationView] |
||||
AS |
||||
SELECT |
||||
* |
||||
FROM |
||||
[dbo].[OrganizationInstallation]; |
||||
@ -0,0 +1,158 @@
@@ -0,0 +1,158 @@
|
||||
-- OrganizationInstallation |
||||
|
||||
-- Table |
||||
IF OBJECT_ID('[dbo].[OrganizationInstallation]') IS NULL |
||||
BEGIN |
||||
CREATE TABLE [dbo].[OrganizationInstallation] ( |
||||
[Id] UNIQUEIDENTIFIER NOT NULL, |
||||
[OrganizationId] UNIQUEIDENTIFIER NOT NULL, |
||||
[InstallationId] UNIQUEIDENTIFIER NOT NULL, |
||||
[CreationDate] DATETIME2 (7) NOT NULL, |
||||
[RevisionDate] DATETIME2 (7) NULL, |
||||
CONSTRAINT [PK_OrganizationInstallation] PRIMARY KEY CLUSTERED ([Id] ASC), |
||||
CONSTRAINT [FK_OrganizationInstallation_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id]) ON DELETE CASCADE, |
||||
CONSTRAINT [FK_OrganizationInstallation_Installation] FOREIGN KEY ([InstallationId]) REFERENCES [dbo].[Installation] ([Id]) ON DELETE CASCADE |
||||
); |
||||
END |
||||
GO |
||||
|
||||
-- Indexes |
||||
IF NOT EXISTS(SELECT name FROM sys.indexes WHERE name = 'IX_OrganizationInstallation_OrganizationId') |
||||
BEGIN |
||||
CREATE NONCLUSTERED INDEX [IX_OrganizationInstallation_OrganizationId] |
||||
ON [dbo].[OrganizationInstallation]([OrganizationId] ASC); |
||||
END |
||||
|
||||
IF NOT EXISTS(SELECT name FROM sys.indexes WHERE name = 'IX_OrganizationInstallation_InstallationId') |
||||
BEGIN |
||||
CREATE NONCLUSTERED INDEX [IX_OrganizationInstallation_InstallationId] |
||||
ON [dbo].[OrganizationInstallation]([InstallationId] ASC); |
||||
END |
||||
|
||||
-- View |
||||
IF EXISTS(SELECT * FROM sys.views WHERE [Name] = 'OrganizationInstallationView') |
||||
BEGIN |
||||
DROP VIEW [dbo].[OrganizationInstallationView]; |
||||
END |
||||
GO |
||||
|
||||
CREATE VIEW [dbo].[OrganizationInstallationView] |
||||
AS |
||||
SELECT |
||||
* |
||||
FROM |
||||
[dbo].[OrganizationInstallation] |
||||
GO |
||||
|
||||
-- Stored Procedures: Create |
||||
CREATE OR ALTER PROCEDURE [dbo].[OrganizationInstallation_Create] |
||||
@Id UNIQUEIDENTIFIER OUTPUT, |
||||
@OrganizationId UNIQUEIDENTIFIER, |
||||
@InstallationId UNIQUEIDENTIFIER, |
||||
@CreationDate DATETIME2 (7), |
||||
@RevisionDate DATETIME2 (7) = NULL |
||||
AS |
||||
BEGIN |
||||
SET NOCOUNT ON |
||||
|
||||
INSERT INTO [dbo].[OrganizationInstallation] |
||||
( |
||||
[Id], |
||||
[OrganizationId], |
||||
[InstallationId], |
||||
[CreationDate], |
||||
[RevisionDate] |
||||
) |
||||
VALUES |
||||
( |
||||
@Id, |
||||
@OrganizationId, |
||||
@InstallationId, |
||||
@CreationDate, |
||||
@RevisionDate |
||||
) |
||||
END |
||||
GO |
||||
|
||||
-- Stored Procedures: DeleteById |
||||
CREATE OR ALTER PROCEDURE [dbo].[OrganizationInstallation_DeleteById] |
||||
@Id UNIQUEIDENTIFIER |
||||
AS |
||||
BEGIN |
||||
SET NOCOUNT ON |
||||
|
||||
DELETE |
||||
FROM |
||||
[dbo].[OrganizationInstallation] |
||||
WHERE |
||||
[Id] = @Id |
||||
END |
||||
GO |
||||
|
||||
-- Stored Procedures: ReadById |
||||
CREATE PROCEDURE [dbo].[OrganizationInstallation_ReadById] |
||||
@Id UNIQUEIDENTIFIER |
||||
AS |
||||
BEGIN |
||||
SET NOCOUNT ON |
||||
|
||||
SELECT |
||||
* |
||||
FROM |
||||
[dbo].[OrganizationInstallationView] |
||||
WHERE |
||||
[Id] = @Id |
||||
END |
||||
GO |
||||
|
||||
-- Stored Procedures: ReadByInstallationId |
||||
CREATE PROCEDURE [dbo].[OrganizationInstallation_ReadByInstallationId] |
||||
@InstallationId UNIQUEIDENTIFIER |
||||
AS |
||||
BEGIN |
||||
SET NOCOUNT ON |
||||
|
||||
SELECT |
||||
* |
||||
FROM |
||||
[dbo].[OrganizationInstallationView] |
||||
WHERE |
||||
[InstallationId] = @InstallationId |
||||
END |
||||
GO |
||||
|
||||
-- Stored Procedures: ReadByOrganizationId |
||||
CREATE PROCEDURE [dbo].[OrganizationInstallation_ReadByOrganizationId] |
||||
@OrganizationId UNIQUEIDENTIFIER |
||||
AS |
||||
BEGIN |
||||
SET NOCOUNT ON |
||||
|
||||
SELECT |
||||
* |
||||
FROM |
||||
[dbo].[OrganizationInstallationView] |
||||
WHERE |
||||
[OrganizationId] = @OrganizationId |
||||
END |
||||
GO |
||||
|
||||
-- Stored Procedures: Update |
||||
CREATE PROCEDURE [dbo].[OrganizationInstallation_Update] |
||||
@Id UNIQUEIDENTIFIER OUTPUT, |
||||
@OrganizationId UNIQUEIDENTIFIER, |
||||
@InstallationId UNIQUEIDENTIFIER, |
||||
@CreationDate DATETIME2 (7), |
||||
@RevisionDate DATETIME2 (7) |
||||
AS |
||||
BEGIN |
||||
SET NOCOUNT ON |
||||
|
||||
UPDATE |
||||
[dbo].[OrganizationInstallation] |
||||
SET |
||||
[RevisionDate] = @RevisionDate |
||||
WHERE |
||||
[Id] = @Id |
||||
END |
||||
GO |
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,58 @@
@@ -0,0 +1,58 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
||||
#nullable disable |
||||
|
||||
namespace Bit.MySqlMigrations.Migrations; |
||||
|
||||
/// <inheritdoc /> |
||||
public partial class AddTable_OrganizationInstallation : Migration |
||||
{ |
||||
/// <inheritdoc /> |
||||
protected override void Up(MigrationBuilder migrationBuilder) |
||||
{ |
||||
migrationBuilder.CreateTable( |
||||
name: "OrganizationInstallation", |
||||
columns: table => new |
||||
{ |
||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
OrganizationId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
InstallationId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
CreationDate = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
RevisionDate = table.Column<DateTime>(type: "datetime(6)", nullable: true) |
||||
}, |
||||
constraints: table => |
||||
{ |
||||
table.PrimaryKey("PK_OrganizationInstallation", x => x.Id); |
||||
table.ForeignKey( |
||||
name: "FK_OrganizationInstallation_Installation_InstallationId", |
||||
column: x => x.InstallationId, |
||||
principalTable: "Installation", |
||||
principalColumn: "Id", |
||||
onDelete: ReferentialAction.Cascade); |
||||
table.ForeignKey( |
||||
name: "FK_OrganizationInstallation_Organization_OrganizationId", |
||||
column: x => x.OrganizationId, |
||||
principalTable: "Organization", |
||||
principalColumn: "Id", |
||||
onDelete: ReferentialAction.Cascade); |
||||
}) |
||||
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
||||
migrationBuilder.CreateIndex( |
||||
name: "IX_OrganizationInstallation_InstallationId", |
||||
table: "OrganizationInstallation", |
||||
column: "InstallationId"); |
||||
|
||||
migrationBuilder.CreateIndex( |
||||
name: "IX_OrganizationInstallation_OrganizationId", |
||||
table: "OrganizationInstallation", |
||||
column: "OrganizationId"); |
||||
} |
||||
|
||||
/// <inheritdoc /> |
||||
protected override void Down(MigrationBuilder migrationBuilder) |
||||
{ |
||||
migrationBuilder.DropTable( |
||||
name: "OrganizationInstallation"); |
||||
} |
||||
} |
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,57 @@
@@ -0,0 +1,57 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
||||
#nullable disable |
||||
|
||||
namespace Bit.PostgresMigrations.Migrations; |
||||
|
||||
/// <inheritdoc /> |
||||
public partial class AddTable_OrganizationInstallation : Migration |
||||
{ |
||||
/// <inheritdoc /> |
||||
protected override void Up(MigrationBuilder migrationBuilder) |
||||
{ |
||||
migrationBuilder.CreateTable( |
||||
name: "OrganizationInstallation", |
||||
columns: table => new |
||||
{ |
||||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
||||
OrganizationId = table.Column<Guid>(type: "uuid", nullable: false), |
||||
InstallationId = table.Column<Guid>(type: "uuid", nullable: false), |
||||
CreationDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
||||
RevisionDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: true) |
||||
}, |
||||
constraints: table => |
||||
{ |
||||
table.PrimaryKey("PK_OrganizationInstallation", x => x.Id); |
||||
table.ForeignKey( |
||||
name: "FK_OrganizationInstallation_Installation_InstallationId", |
||||
column: x => x.InstallationId, |
||||
principalTable: "Installation", |
||||
principalColumn: "Id", |
||||
onDelete: ReferentialAction.Cascade); |
||||
table.ForeignKey( |
||||
name: "FK_OrganizationInstallation_Organization_OrganizationId", |
||||
column: x => x.OrganizationId, |
||||
principalTable: "Organization", |
||||
principalColumn: "Id", |
||||
onDelete: ReferentialAction.Cascade); |
||||
}); |
||||
|
||||
migrationBuilder.CreateIndex( |
||||
name: "IX_OrganizationInstallation_InstallationId", |
||||
table: "OrganizationInstallation", |
||||
column: "InstallationId"); |
||||
|
||||
migrationBuilder.CreateIndex( |
||||
name: "IX_OrganizationInstallation_OrganizationId", |
||||
table: "OrganizationInstallation", |
||||
column: "OrganizationId"); |
||||
} |
||||
|
||||
/// <inheritdoc /> |
||||
protected override void Down(MigrationBuilder migrationBuilder) |
||||
{ |
||||
migrationBuilder.DropTable( |
||||
name: "OrganizationInstallation"); |
||||
} |
||||
} |
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,57 @@
@@ -0,0 +1,57 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
||||
#nullable disable |
||||
|
||||
namespace Bit.SqliteMigrations.Migrations; |
||||
|
||||
/// <inheritdoc /> |
||||
public partial class AddTable_OrganizationInstallation : Migration |
||||
{ |
||||
/// <inheritdoc /> |
||||
protected override void Up(MigrationBuilder migrationBuilder) |
||||
{ |
||||
migrationBuilder.CreateTable( |
||||
name: "OrganizationInstallation", |
||||
columns: table => new |
||||
{ |
||||
Id = table.Column<Guid>(type: "TEXT", nullable: false), |
||||
OrganizationId = table.Column<Guid>(type: "TEXT", nullable: false), |
||||
InstallationId = table.Column<Guid>(type: "TEXT", nullable: false), |
||||
CreationDate = table.Column<DateTime>(type: "TEXT", nullable: false), |
||||
RevisionDate = table.Column<DateTime>(type: "TEXT", nullable: true) |
||||
}, |
||||
constraints: table => |
||||
{ |
||||
table.PrimaryKey("PK_OrganizationInstallation", x => x.Id); |
||||
table.ForeignKey( |
||||
name: "FK_OrganizationInstallation_Installation_InstallationId", |
||||
column: x => x.InstallationId, |
||||
principalTable: "Installation", |
||||
principalColumn: "Id", |
||||
onDelete: ReferentialAction.Cascade); |
||||
table.ForeignKey( |
||||
name: "FK_OrganizationInstallation_Organization_OrganizationId", |
||||
column: x => x.OrganizationId, |
||||
principalTable: "Organization", |
||||
principalColumn: "Id", |
||||
onDelete: ReferentialAction.Cascade); |
||||
}); |
||||
|
||||
migrationBuilder.CreateIndex( |
||||
name: "IX_OrganizationInstallation_InstallationId", |
||||
table: "OrganizationInstallation", |
||||
column: "InstallationId"); |
||||
|
||||
migrationBuilder.CreateIndex( |
||||
name: "IX_OrganizationInstallation_OrganizationId", |
||||
table: "OrganizationInstallation", |
||||
column: "OrganizationId"); |
||||
} |
||||
|
||||
/// <inheritdoc /> |
||||
protected override void Down(MigrationBuilder migrationBuilder) |
||||
{ |
||||
migrationBuilder.DropTable( |
||||
name: "OrganizationInstallation"); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue