-
Notifications
You must be signed in to change notification settings - Fork 7
/
Migrations.cs
52 lines (49 loc) · 1.89 KB
/
Migrations.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
using Orchard.Data.Migration;
namespace Q42.DbTranslations
{
public class Migrations : DataMigrationImpl
{
public int Create()
{
SchemaBuilder.CreateTable(
"LocalizableStringRecord",
table =>
table
.Column<int>("Id", column => column.PrimaryKey().Identity())
.Column<string>("Path")
.Column<string>("Context")
.Column<string>("StringKey", column => column.WithLength(4000))
.Column<string>("OriginalLanguageString",
column => column.WithLength(4000))
);
SchemaBuilder.CreateTable(
"TranslationRecord",
table =>
table
.Column<int>("Id", column => column.PrimaryKey().Identity())
.Column<string>("Culture")
.Column<string>("Value", column => column.WithLength(4000))
.Column<int>("LocalizableStringRecord_Id")
)
//ForeignKey names must be unique, so enforce this using part of GUID
//Goes wrong when multitenancy is used with table prefixes in same database
.CreateForeignKey(
string.Format("FK_Po_Translation_LocalizableString_{0}", System.Guid.NewGuid().ToString("N").Substring(0, 16).ToUpper()),
"Q42.DbTranslations", "TranslationRecord",
new[] { "LocalizableStringRecord_Id" },
"Q42.DbTranslations", "LocalizableStringRecord",
new[] { "Id" });
SchemaBuilder.AlterTable(
"TranslationRecord",
table => table.CreateIndex(
"Index_Po_Translation_LocalizableStringRecord_Id",
"LocalizableStringRecord_Id"));
return 1;
}
public int UpdateFrom1()
{
SchemaBuilder.ExecuteSql(@"DELETE FROM Q42_DbTranslations_LocalizableStringRecord WHERE [Path] LIKE '%_Backup%' OR Context LIKE '%_Backup%'");
return 2;
}
}
}