@itrocks/mysql-maintainer 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/mysql-maintainer.js
CHANGED
|
@@ -36,12 +36,13 @@ class MysqlMaintainer {
|
|
|
36
36
|
throw 'Collection objects are not stored';
|
|
37
37
|
}
|
|
38
38
|
const joinTable = (0, mysql_1.joinTableName)(table1, table2);
|
|
39
|
-
const query =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
const query = `CREATE TABLE \`${joinTable}\` (
|
|
40
|
+
${table1}_id int unsigned NOT NULL,
|
|
41
|
+
${table2}_id int unsigned NOT NULL,
|
|
42
|
+
PRIMARY KEY (${table1}_id, ${table2}_id),
|
|
43
|
+
CONSTRAINT \`${joinTable}.${table1}_id\` FOREIGN KEY (${table1}_id) REFERENCES \`${table1}\` (id) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
44
|
+
CONSTRAINT \`${joinTable}.${table2}_id\` FOREIGN KEY (${table2}_id) REFERENCES \`${table2}\` (id) ON DELETE CASCADE ON UPDATE CASCADE
|
|
45
|
+
)`;
|
|
45
46
|
await this.connection.query(query);
|
|
46
47
|
return true;
|
|
47
48
|
}
|
package/esm/mysql-maintainer.js
CHANGED
|
@@ -19,12 +19,13 @@ export class MysqlMaintainer {
|
|
|
19
19
|
throw 'Collection objects are not stored';
|
|
20
20
|
}
|
|
21
21
|
const joinTable = joinTableName(table1, table2);
|
|
22
|
-
const query =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
const query = `CREATE TABLE \`${joinTable}\` (
|
|
23
|
+
${table1}_id int unsigned NOT NULL,
|
|
24
|
+
${table2}_id int unsigned NOT NULL,
|
|
25
|
+
PRIMARY KEY (${table1}_id, ${table2}_id),
|
|
26
|
+
CONSTRAINT \`${joinTable}.${table1}_id\` FOREIGN KEY (${table1}_id) REFERENCES \`${table1}\` (id) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
27
|
+
CONSTRAINT \`${joinTable}.${table2}_id\` FOREIGN KEY (${table2}_id) REFERENCES \`${table2}\` (id) ON DELETE CASCADE ON UPDATE CASCADE
|
|
28
|
+
)`;
|
|
28
29
|
await this.connection.query(query);
|
|
29
30
|
return true;
|
|
30
31
|
}
|
package/package.json
CHANGED