forked from oqtane/oqtane.framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OqtaneHistoryRepository.cs
53 lines (46 loc) · 1.85 KB
/
OqtaneHistoryRepository.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Text;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.SqlServer.Migrations.Internal;
using Microsoft.EntityFrameworkCore.Storage;
using Oqtane.Migrations.Framework;
using Oqtane.Models;
using Oqtane.Shared;
// ReSharper disable ClassNeverInstantiated.Global
namespace Oqtane.Database.SqlServer
{
public class OqtaneHistoryRepository : SqlServerHistoryRepository
{
private string _appliedDateColumnName = "AppliedDate";
private string _appliedVersionColumnName = "AppliedVersion";
private MigrationHistoryTable _migrationHistoryTable;
public OqtaneHistoryRepository(HistoryRepositoryDependencies dependencies) : base(dependencies)
{
_migrationHistoryTable = new MigrationHistoryTable
{
TableName = TableName,
TableSchema = TableSchema,
MigrationIdColumnName = MigrationIdColumnName,
ProductVersionColumnName = ProductVersionColumnName,
AppliedVersionColumnName = _appliedVersionColumnName,
AppliedDateColumnName = _appliedDateColumnName
};
}
protected override void ConfigureTable(EntityTypeBuilder<HistoryRow> history)
{
base.ConfigureTable(history);
history.Property<string>(_appliedVersionColumnName).HasMaxLength(10);
history.Property<DateTime>(_appliedDateColumnName);
}
public override string GetInsertScript(HistoryRow row)
{
if (row == null)
{
throw new ArgumentNullException(nameof(row));
}
return MigrationUtils.BuildInsertScript(row, Dependencies, _migrationHistoryTable);
}
}
}