@@ -13,7 +13,19 @@ var sql = `CREATE TABLE "humanresources_department" (
13
13
"groupname" Name NOT NULL,
14
14
"modifieddate" timestamp NOT NULL,
15
15
PRIMARY KEY("departmentid")
16
- ); `
16
+ );
17
+
18
+ CREATE TABLE "humanresources_employeedepartmenthistory" (
19
+ "businessentityid" int(4) NOT NULL,
20
+ "departmentid" int(2) NOT NULL,
21
+ "shiftid" int(2) NOT NULL,
22
+ "startdate" date NOT NULL,
23
+ "enddate" date,
24
+ "modifieddate" timestamp NOT NULL,
25
+ PRIMARY KEY("businessentityid","departmentid","shiftid","startdate"),
26
+ FOREIGN KEY ("departmentid") REFERENCES "humanresources_department"("departmentid")
27
+ );
28
+ `
17
29
18
30
// run parser
19
31
const parser = new SqlSimpleParser (' postgres' )
@@ -34,7 +46,15 @@ const models = parser
34
46
"Name" : " departmentid" ,
35
47
"ColumnProperties" : " serial NOT NULL" ,
36
48
"TableName" : " humanresources_department" ,
37
- "ForeignKey" : [],
49
+ "ForeignKey" : [
50
+ {
51
+ "PrimaryKeyTableName" : " humanresources_employeedepartmenthistory" ,
52
+ "PrimaryKeyName" : " departmentid" ,
53
+ "ReferencesPropertyName" : " departmentid" ,
54
+ "ReferencesTableName" : " humanresources_department" ,
55
+ "IsDestination" : true
56
+ }
57
+ ],
38
58
"IsForeignKey" : false ,
39
59
"IsPrimaryKey" : true
40
60
},
@@ -63,14 +83,94 @@ const models = parser
63
83
"IsPrimaryKey" : false
64
84
}
65
85
]
86
+ },
87
+ {
88
+ "Name" : " humanresources_employeedepartmenthistory" ,
89
+ "Properties" : [
90
+ {
91
+ "Name" : " businessentityid" ,
92
+ "ColumnProperties" : " int(4) NOT NULL" ,
93
+ "TableName" : " humanresources_employeedepartmenthistory" ,
94
+ "ForeignKey" : [],
95
+ "IsForeignKey" : false ,
96
+ "IsPrimaryKey" : false
97
+ },
98
+ {
99
+ "Name" : " departmentid" ,
100
+ "ColumnProperties" : " int(2) NOT NULL" ,
101
+ "TableName" : " humanresources_employeedepartmenthistory" ,
102
+ "ForeignKey" : [
103
+ {
104
+ "PrimaryKeyTableName" : " humanresources_department" ,
105
+ "PrimaryKeyName" : " departmentid" ,
106
+ "ReferencesPropertyName" : " departmentid" ,
107
+ "ReferencesTableName" : " humanresources_employeedepartmenthistory" ,
108
+ "IsDestination" : false
109
+ }
110
+ ],
111
+ "IsForeignKey" : true ,
112
+ "IsPrimaryKey" : false
113
+ },
114
+ {
115
+ "Name" : " shiftid" ,
116
+ "ColumnProperties" : " int(2) NOT NULL" ,
117
+ "TableName" : " humanresources_employeedepartmenthistory" ,
118
+ "ForeignKey" : [],
119
+ "IsForeignKey" : false ,
120
+ "IsPrimaryKey" : false
121
+ },
122
+ {
123
+ "Name" : " startdate" ,
124
+ "ColumnProperties" : " date NOT NULL" ,
125
+ "TableName" : " humanresources_employeedepartmenthistory" ,
126
+ "ForeignKey" : [],
127
+ "IsForeignKey" : false ,
128
+ "IsPrimaryKey" : false
129
+ },
130
+ {
131
+ "Name" : " enddate" ,
132
+ "ColumnProperties" : " date" ,
133
+ "TableName" : " humanresources_employeedepartmenthistory" ,
134
+ "ForeignKey" : [],
135
+ "IsForeignKey" : false ,
136
+ "IsPrimaryKey" : false
137
+ },
138
+ {
139
+ "Name" : " modifieddate" ,
140
+ "ColumnProperties" : " timestamp NOT NULL" ,
141
+ "TableName" : " humanresources_employeedepartmenthistory" ,
142
+ "ForeignKey" : [],
143
+ "IsForeignKey" : false ,
144
+ "IsPrimaryKey" : false
145
+ }
146
+ ]
147
+ }
148
+ ],
149
+ "Dialect" : " postgres" ,
150
+ "ForeignKeyList" : [
151
+ {
152
+ "PrimaryKeyTableName" : " humanresources_employeedepartmenthistory" ,
153
+ "PrimaryKeyName" : " departmentid" ,
154
+ "ReferencesPropertyName" : " departmentid" ,
155
+ "ReferencesTableName" : " humanresources_department" ,
156
+ "IsDestination" : true
157
+ },
158
+ {
159
+ "PrimaryKeyTableName" : " humanresources_department" ,
160
+ "PrimaryKeyName" : " departmentid" ,
161
+ "ReferencesPropertyName" : " departmentid" ,
162
+ "ReferencesTableName" : " humanresources_employeedepartmenthistory" ,
163
+ "IsDestination" : false
66
164
}
67
165
],
68
- "Dialect" : " sqlserver" ,
69
- "ForeignKeyList" : [],
70
166
"PrimaryKeyList" : [
71
167
{
72
168
"PrimaryKeyTableName" : " humanresources_department" ,
73
169
"PrimaryKeyName" : " departmentid"
170
+ },
171
+ {
172
+ "PrimaryKeyTableName" : " humanresources_employeedepartmenthistory" ,
173
+ "PrimaryKeyName" : " businessentityid,departmentid,shiftid,startdate"
74
174
}
75
175
]
76
176
}
0 commit comments