@@ -20,6 +20,35 @@ public void downgrade(EOEditingContext editingContext, ERXMigrationDatabase data
20
20
21
21
@ Override
22
22
public void upgrade (EOEditingContext editingContext , ERXMigrationDatabase database ) throws Throwable {
23
+ ERXMigrationTable blogCategoryTable = database .newTableNamed ("BlogCategory" );
24
+ blogCategoryTable .newIntegerColumn ("id" , false );
25
+ blogCategoryTable .newStringColumn ("name" , 100 , false );
26
+ blogCategoryTable .newStringColumn ("shortName" , 50 , false );
27
+ blogCategoryTable .create ();
28
+ blogCategoryTable .setPrimaryKey ("id" );
29
+
30
+ ERXMigrationTable blogEntryTable = database .newTableNamed ("BlogEntry" );
31
+ blogEntryTable .newStringColumn ("body" , 10000000 , false );
32
+ blogEntryTable .newIntegerColumn ("id" , false );
33
+ blogEntryTable .newTimestampColumn ("lastModifed" , false );
34
+ blogEntryTable .newIntegerColumn ("personID" , false );
35
+ blogEntryTable .newTimestampColumn ("timestampCreation" , false );
36
+ blogEntryTable .newStringColumn ("title" , 255 , false );
37
+ blogEntryTable .create ();
38
+ blogEntryTable .setPrimaryKey ("id" );
39
+
40
+ ERXMigrationTable xPersonRoleTable = database .newTableNamed ("XPersonRole" );
41
+ xPersonRoleTable .newIntegerColumn ("personId" , false );
42
+ xPersonRoleTable .newIntegerColumn ("roleId" , false );
43
+ xPersonRoleTable .create ();
44
+ xPersonRoleTable .setPrimaryKey ("roleId" , "personId" );
45
+
46
+ ERXMigrationTable blogCategoryEntryTable = database .newTableNamed ("BlogCategoryEntry" );
47
+ blogCategoryEntryTable .newIntegerColumn ("blogCategoryId" , false );
48
+ blogCategoryEntryTable .newIntegerColumn ("blogEntryId" , false );
49
+ blogCategoryEntryTable .create ();
50
+ blogCategoryEntryTable .setPrimaryKey ("blogCategoryId" , "blogEntryId" );
51
+
23
52
ERXMigrationTable personTable = database .newTableNamed ("Person" );
24
53
personTable .newStringColumn ("email" , 255 , true );
25
54
personTable .newStringColumn ("firstName" , 255 , true );
@@ -36,23 +65,10 @@ public void upgrade(EOEditingContext editingContext, ERXMigrationDatabase databa
36
65
roleTable .create ();
37
66
roleTable .setPrimaryKey ("id" );
38
67
39
- ERXMigrationTable xPersonRoleTable = database .newTableNamed ("XPersonRole" );
40
- xPersonRoleTable .newIntegerColumn ("personId" , false );
41
- xPersonRoleTable .newIntegerColumn ("roleId" , false );
42
- xPersonRoleTable .create ();
43
- xPersonRoleTable .setPrimaryKey ("roleId" , "personId" );
44
-
45
- ERXMigrationTable blogEntryTable = database .newTableNamed ("BlogEntry" );
46
- blogEntryTable .newStringColumn ("body" , 10000000 , false );
47
- blogEntryTable .newIntegerColumn ("id" , false );
48
- blogEntryTable .newIntegerColumn ("personID" , false );
49
- blogEntryTable .newTimestampColumn ("timestampCreation" , false );
50
- blogEntryTable .newStringColumn ("title" , 255 , false );
51
- blogEntryTable .create ();
52
- blogEntryTable .setPrimaryKey ("id" );
53
-
68
+ blogEntryTable .addForeignKey ("personID" , "Person" , "id" );
54
69
xPersonRoleTable .addForeignKey ("personId" , "Person" , "id" );
55
70
xPersonRoleTable .addForeignKey ("roleId" , "Role" , "id" );
56
- blogEntryTable .addForeignKey ("personID" , "Person" , "id" );
71
+ blogCategoryEntryTable .addForeignKey ("blogCategoryId" , "BlogCategory" , "id" );
72
+ blogCategoryEntryTable .addForeignKey ("blogEntryId" , "BlogEntry" , "id" );
57
73
}
58
74
}
0 commit comments