@@ -13,7 +13,19 @@ var sql = `CREATE TABLE "humanresources_department" (
1313 "groupname" Name NOT NULL,
1414 "modifieddate" timestamp NOT NULL,
1515 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+ `
1729
1830// run parser
1931const parser = new SqlSimpleParser (' postgres' )
@@ -34,7 +46,15 @@ const models = parser
3446 "Name" : " departmentid" ,
3547 "ColumnProperties" : " serial NOT NULL" ,
3648 "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+ ],
3858 "IsForeignKey" : false ,
3959 "IsPrimaryKey" : true
4060 },
@@ -63,14 +83,94 @@ const models = parser
6383 "IsPrimaryKey" : false
6484 }
6585 ]
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
66164 }
67165 ],
68- "Dialect" : " sqlserver" ,
69- "ForeignKeyList" : [],
70166 "PrimaryKeyList" : [
71167 {
72168 "PrimaryKeyTableName" : " humanresources_department" ,
73169 "PrimaryKeyName" : " departmentid"
170+ },
171+ {
172+ "PrimaryKeyTableName" : " humanresources_employeedepartmenthistory" ,
173+ "PrimaryKeyName" : " businessentityid,departmentid,shiftid,startdate"
74174 }
75175 ]
76176}
0 commit comments