@nymphjs/driver-mysql 1.0.0-beta.105 → 1.0.0-beta.107
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/CHANGELOG.md +13 -0
- package/dist/MySQLDriver.d.ts +12 -2
- package/dist/MySQLDriver.js +175 -57
- package/dist/MySQLDriver.js.map +1 -1
- package/dist/MySQLDriver.test.js +3 -0
- package/dist/MySQLDriver.test.js.map +1 -1
- package/package.json +11 -10
- package/src/MySQLDriver.test.ts +4 -0
- package/src/MySQLDriver.ts +303 -73
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,19 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.0.0-beta.107](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.106...v1.0.0-beta.107) (2026-02-13)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- move tilmeld fields into columns in entities tables ([5f46048](https://github.com/sciactive/nymphjs/commit/5f46048c3e04839ca9a8b81f71a950b9086d0a41))
|
|
11
|
+
- update packages and fix all new issues ([0e9d17c](https://github.com/sciactive/nymphjs/commit/0e9d17c6e2db12c11bdfb559031719c1b52b5fa1))
|
|
12
|
+
|
|
13
|
+
# [1.0.0-beta.106](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.105...v1.0.0-beta.106) (2025-12-05)
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
- don't sort qref queries unless explicitly told to ([e92c413](https://github.com/sciactive/nymphjs/commit/e92c413800032a9347a06f965281263a55c9547b))
|
|
18
|
+
|
|
6
19
|
# [1.0.0-beta.105](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.104...v1.0.0-beta.105) (2025-12-04)
|
|
7
20
|
|
|
8
21
|
### Features
|
package/dist/MySQLDriver.d.ts
CHANGED
|
@@ -45,6 +45,8 @@ export default class MySQLDriver extends NymphDriver {
|
|
|
45
45
|
*/
|
|
46
46
|
isConnected(): boolean;
|
|
47
47
|
private createEntitiesTable;
|
|
48
|
+
private addTilmeldColumnsAndIndexes;
|
|
49
|
+
private createEntitiesTilmeldIndexes;
|
|
48
50
|
private createDataTable;
|
|
49
51
|
private createReferencesTable;
|
|
50
52
|
private createTokensTable;
|
|
@@ -121,6 +123,14 @@ export default class MySQLDriver extends NymphDriver {
|
|
|
121
123
|
sdata: SerializedEntityData;
|
|
122
124
|
etype: string;
|
|
123
125
|
}): Promise<void>;
|
|
126
|
+
importEntityTilmeldAC(entity: {
|
|
127
|
+
guid: string;
|
|
128
|
+
cdate: number;
|
|
129
|
+
mdate: number;
|
|
130
|
+
tags: string[];
|
|
131
|
+
sdata: SerializedEntityData;
|
|
132
|
+
etype: string;
|
|
133
|
+
}): Promise<void>;
|
|
124
134
|
private importEntityInternal;
|
|
125
135
|
importUID({ name, value }: {
|
|
126
136
|
name: string;
|
|
@@ -133,7 +143,7 @@ export default class MySQLDriver extends NymphDriver {
|
|
|
133
143
|
setUID(name: string, curUid: number): Promise<boolean>;
|
|
134
144
|
protected internalTransaction(name: string): Promise<MySQLDriverTransaction>;
|
|
135
145
|
startTransaction(name: string): Promise<import("@nymphjs/nymph").Nymph>;
|
|
136
|
-
needsMigration(): Promise<'json' | 'tokens' | false>;
|
|
137
|
-
liveMigration(
|
|
146
|
+
needsMigration(): Promise<'json' | 'tokens' | 'tilmeldColumns' | false>;
|
|
147
|
+
liveMigration(migrationType: 'tokenTables' | 'tilmeldColumns'): Promise<void>;
|
|
138
148
|
}
|
|
139
149
|
export {};
|
package/dist/MySQLDriver.js
CHANGED
|
@@ -129,14 +129,51 @@ export default class MySQLDriver extends NymphDriver {
|
|
|
129
129
|
\`tags\` LONGTEXT,
|
|
130
130
|
\`cdate\` DOUBLE PRECISION NOT NULL,
|
|
131
131
|
\`mdate\` DOUBLE PRECISION NOT NULL,
|
|
132
|
+
\`user\` BINARY(12),
|
|
133
|
+
\`group\` BINARY(12),
|
|
134
|
+
\`acUser\` TINYINT UNSIGNED,
|
|
135
|
+
\`acGroup\` TINYINT UNSIGNED,
|
|
136
|
+
\`acOther\` TINYINT UNSIGNED,
|
|
137
|
+
\`acRead\` LONGTEXT,
|
|
138
|
+
\`acWrite\` LONGTEXT,
|
|
139
|
+
\`acFull\` LONGTEXT,
|
|
132
140
|
PRIMARY KEY (\`guid\`),
|
|
133
141
|
INDEX \`id_guid\` USING HASH (\`guid\`),
|
|
134
142
|
INDEX \`id_cdate\` USING BTREE (\`cdate\`),
|
|
135
143
|
INDEX \`id_mdate\` USING BTREE (\`mdate\`),
|
|
136
|
-
FULLTEXT \`id_tags\` (\`tags\`)
|
|
144
|
+
FULLTEXT \`id_tags\` (\`tags\`),
|
|
145
|
+
INDEX \`id_user_acUser\` USING BTREE (\`user\`, \`acUser\`),
|
|
146
|
+
INDEX \`id_group_acGroup\` USING BTREE (\`group\`, \`acGroup\`),
|
|
147
|
+
INDEX \`id_acUser\` USING BTREE (\`acUser\`),
|
|
148
|
+
INDEX \`id_acGroup\` USING BTREE (\`acGroup\`),
|
|
149
|
+
INDEX \`id_acOther\` USING BTREE (\`acOther\`),
|
|
150
|
+
FULLTEXT \`id_acRead\` (\`acRead\`),
|
|
151
|
+
FULLTEXT \`id_acWrite\` (\`acWrite\`),
|
|
152
|
+
FULLTEXT \`id_acFull\` (\`acFull\`)
|
|
137
153
|
) ENGINE ${this.config.engine}
|
|
138
154
|
CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;`);
|
|
139
155
|
}
|
|
156
|
+
async addTilmeldColumnsAndIndexes(etype) {
|
|
157
|
+
await this.queryRun(`ALTER TABLE ${MySQLDriver.escape(`${this.prefix}entities_${etype}`)} ADD COLUMN \`user\` BINARY(12);`);
|
|
158
|
+
await this.queryRun(`ALTER TABLE ${MySQLDriver.escape(`${this.prefix}entities_${etype}`)} ADD COLUMN \`group\` BINARY(12);`);
|
|
159
|
+
await this.queryRun(`ALTER TABLE ${MySQLDriver.escape(`${this.prefix}entities_${etype}`)} ADD COLUMN \`acUser\` TINYINT UNSIGNED;`);
|
|
160
|
+
await this.queryRun(`ALTER TABLE ${MySQLDriver.escape(`${this.prefix}entities_${etype}`)} ADD COLUMN \`acGroup\` TINYINT UNSIGNED;`);
|
|
161
|
+
await this.queryRun(`ALTER TABLE ${MySQLDriver.escape(`${this.prefix}entities_${etype}`)} ADD COLUMN \`acOther\` TINYINT UNSIGNED;`);
|
|
162
|
+
await this.queryRun(`ALTER TABLE ${MySQLDriver.escape(`${this.prefix}entities_${etype}`)} ADD COLUMN \`acRead\` LONGTEXT;`);
|
|
163
|
+
await this.queryRun(`ALTER TABLE ${MySQLDriver.escape(`${this.prefix}entities_${etype}`)} ADD COLUMN \`acWrite\` LONGTEXT;`);
|
|
164
|
+
await this.queryRun(`ALTER TABLE ${MySQLDriver.escape(`${this.prefix}entities_${etype}`)} ADD COLUMN \`acFull\` LONGTEXT;`);
|
|
165
|
+
await this.createEntitiesTilmeldIndexes(etype);
|
|
166
|
+
}
|
|
167
|
+
async createEntitiesTilmeldIndexes(etype) {
|
|
168
|
+
await this.queryRun(`CREATE INDEX \`id_user_acUser\` ON ${MySQLDriver.escape(`${this.prefix}entities_${etype}`)} (\`user\`, \`acUser\`) USING BTREE;`);
|
|
169
|
+
await this.queryRun(`CREATE INDEX \`id_group_acGroup\` ON ${MySQLDriver.escape(`${this.prefix}entities_${etype}`)} (\`group\`, \`acGroup\`) USING BTREE;`);
|
|
170
|
+
await this.queryRun(`CREATE INDEX \`id_acUser\` ON ${MySQLDriver.escape(`${this.prefix}entities_${etype}`)} (\`acUser\`) USING BTREE;`);
|
|
171
|
+
await this.queryRun(`CREATE INDEX \`id_acGroup\` ON ${MySQLDriver.escape(`${this.prefix}entities_${etype}`)} (\`acGroup\`) USING BTREE;`);
|
|
172
|
+
await this.queryRun(`CREATE INDEX \`id_acOther\` ON ${MySQLDriver.escape(`${this.prefix}entities_${etype}`)} (\`acOther\`) USING BTREE;`);
|
|
173
|
+
await this.queryRun(`CREATE FULLTEXT INDEX \`id_acRead\` ON ${MySQLDriver.escape(`${this.prefix}entities_${etype}`)} (\`acRead\`);`);
|
|
174
|
+
await this.queryRun(`CREATE FULLTEXT INDEX \`id_acWrite\` ON ${MySQLDriver.escape(`${this.prefix}entities_${etype}`)} (\`acWrite\`);`);
|
|
175
|
+
await this.queryRun(`CREATE FULLTEXT INDEX \`id_acFull\` ON ${MySQLDriver.escape(`${this.prefix}entities_${etype}`)} (\`acFull\`);`);
|
|
176
|
+
}
|
|
140
177
|
async createDataTable(etype) {
|
|
141
178
|
let foreignKey = '';
|
|
142
179
|
if (this.config.foreignKeys) {
|
|
@@ -1523,14 +1560,14 @@ export default class MySQLDriver extends NymphDriver {
|
|
|
1523
1560
|
break;
|
|
1524
1561
|
case 'selector':
|
|
1525
1562
|
case '!selector':
|
|
1526
|
-
const
|
|
1563
|
+
const innerquery = this.makeEntityQuery({ ...options, sort: null, limit: undefined }, [curValue], etype, count, params, true, tableSuffix, etypes);
|
|
1527
1564
|
if (curQuery) {
|
|
1528
1565
|
curQuery += typeIsOr ? ' OR ' : ' AND ';
|
|
1529
1566
|
}
|
|
1530
1567
|
curQuery +=
|
|
1531
1568
|
(xor(typeIsNot, clauseNot) ? 'NOT ' : '') +
|
|
1532
1569
|
'(' +
|
|
1533
|
-
|
|
1570
|
+
innerquery.query +
|
|
1534
1571
|
')';
|
|
1535
1572
|
break;
|
|
1536
1573
|
case 'qref':
|
|
@@ -1539,7 +1576,12 @@ export default class MySQLDriver extends NymphDriver {
|
|
|
1539
1576
|
const [qrefOptions, ...qrefSelectors] = curValue[1];
|
|
1540
1577
|
const QrefEntityClass = qrefOptions.class;
|
|
1541
1578
|
etypes.push(QrefEntityClass.ETYPE);
|
|
1542
|
-
const qrefQuery = this.makeEntityQuery({
|
|
1579
|
+
const qrefQuery = this.makeEntityQuery({
|
|
1580
|
+
...qrefOptions,
|
|
1581
|
+
sort: qrefOptions.sort ?? null,
|
|
1582
|
+
return: 'guid',
|
|
1583
|
+
class: QrefEntityClass,
|
|
1584
|
+
}, qrefSelectors, QrefEntityClass.ETYPE, count, params, false, makeTableSuffix(), etypes, 'r' + referenceTableSuffix + '.`reference`');
|
|
1543
1585
|
if (curQuery) {
|
|
1544
1586
|
curQuery += typeIsOr ? ' OR ' : ' AND ';
|
|
1545
1587
|
}
|
|
@@ -1815,15 +1857,18 @@ export default class MySQLDriver extends NymphDriver {
|
|
|
1815
1857
|
return result?.cur_uid ?? null;
|
|
1816
1858
|
}
|
|
1817
1859
|
async importEntity(entity) {
|
|
1818
|
-
return await this.importEntityInternal(entity
|
|
1860
|
+
return await this.importEntityInternal(entity);
|
|
1819
1861
|
}
|
|
1820
1862
|
async importEntityTokens(entity) {
|
|
1821
|
-
return await this.importEntityInternal(entity,
|
|
1863
|
+
return await this.importEntityInternal(entity, { only: 'tokens' });
|
|
1864
|
+
}
|
|
1865
|
+
async importEntityTilmeldAC(entity) {
|
|
1866
|
+
return await this.importEntityInternal(entity, { only: 'tilmeldAC' });
|
|
1822
1867
|
}
|
|
1823
|
-
async importEntityInternal({ guid, cdate, mdate, tags, sdata, etype, },
|
|
1868
|
+
async importEntityInternal({ guid, cdate, mdate, tags, sdata, etype, }, { only = undefined } = {}) {
|
|
1824
1869
|
try {
|
|
1825
1870
|
let promises = [];
|
|
1826
|
-
if (
|
|
1871
|
+
if (only == null) {
|
|
1827
1872
|
promises.push(this.queryRun(`DELETE FROM ${MySQLDriver.escape(`${this.prefix}entities_${etype}`)} WHERE \`guid\`=UNHEX(@guid);`, {
|
|
1828
1873
|
etypes: [etype],
|
|
1829
1874
|
params: {
|
|
@@ -1843,13 +1888,15 @@ export default class MySQLDriver extends NymphDriver {
|
|
|
1843
1888
|
},
|
|
1844
1889
|
}));
|
|
1845
1890
|
}
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1891
|
+
if (only == null || only === 'tokens') {
|
|
1892
|
+
promises.push(this.queryRun(`DELETE FROM ${MySQLDriver.escape(`${this.prefix}tokens_${etype}`)} WHERE \`guid\`=UNHEX(@guid);`, {
|
|
1893
|
+
etypes: [etype],
|
|
1894
|
+
params: {
|
|
1895
|
+
guid,
|
|
1896
|
+
},
|
|
1897
|
+
}));
|
|
1898
|
+
}
|
|
1899
|
+
if (only == null) {
|
|
1853
1900
|
promises.push(this.queryRun(`DELETE FROM ${MySQLDriver.escape(`${this.prefix}uniques_${etype}`)} WHERE \`guid\`=UNHEX(@guid);`, {
|
|
1854
1901
|
etypes: [etype],
|
|
1855
1902
|
params: {
|
|
@@ -1859,14 +1906,23 @@ export default class MySQLDriver extends NymphDriver {
|
|
|
1859
1906
|
}
|
|
1860
1907
|
await Promise.all(promises);
|
|
1861
1908
|
promises = [];
|
|
1862
|
-
if (
|
|
1863
|
-
|
|
1909
|
+
if (only == null) {
|
|
1910
|
+
let { user, group, acUser, acGroup, acOther, acRead, acWrite, acFull } = this.removeAndReturnACValues(etype, {}, sdata);
|
|
1911
|
+
await this.queryRun(`INSERT INTO ${MySQLDriver.escape(`${this.prefix}entities_${etype}`)} (\`guid\`, \`tags\`, \`cdate\`, \`mdate\`, \`user\`, \`group\`, \`acUser\`, \`acGroup\`, \`acOther\`, \`acRead\`, \`acWrite\`, \`acFull\`) VALUES (UNHEX(@guid), @tags, @cdate, @mdate, ${user == null ? '@user' : 'UNHEX(@user)'}, ${group == null ? '@group' : 'UNHEX(@group)'}, @acUser, @acGroup, @acOther, @acRead, @acWrite, @acFull);`, {
|
|
1864
1912
|
etypes: [etype],
|
|
1865
1913
|
params: {
|
|
1866
1914
|
guid,
|
|
1867
1915
|
tags: ' ' + tags.join(' ') + ' ',
|
|
1868
1916
|
cdate: isNaN(cdate) ? null : cdate,
|
|
1869
1917
|
mdate: isNaN(mdate) ? null : mdate,
|
|
1918
|
+
user,
|
|
1919
|
+
group,
|
|
1920
|
+
acUser,
|
|
1921
|
+
acGroup,
|
|
1922
|
+
acOther,
|
|
1923
|
+
acRead: acRead && ' ' + acRead.join(' ') + ' ',
|
|
1924
|
+
acWrite: acWrite && ' ' + acWrite.join(' ') + ' ',
|
|
1925
|
+
acFull: acFull && ' ' + acFull.join(' ') + ' ',
|
|
1870
1926
|
},
|
|
1871
1927
|
});
|
|
1872
1928
|
for (const name in sdata) {
|
|
@@ -1906,45 +1962,64 @@ export default class MySQLDriver extends NymphDriver {
|
|
|
1906
1962
|
}
|
|
1907
1963
|
}
|
|
1908
1964
|
}
|
|
1965
|
+
if (only === 'tilmeldAC') {
|
|
1966
|
+
let { user, group, acUser, acGroup, acOther, acRead, acWrite, acFull } = this.removeAndReturnACValues(etype, {}, sdata);
|
|
1967
|
+
promises.push(this.queryRun(`UPDATE ${MySQLDriver.escape(`${this.prefix}entities_${etype}`)} SET \`user\`=${user == null ? '@user' : 'UNHEX(@user)'}, \`group\`=${group == null ? '@group' : 'UNHEX(@group)'}, \`acUser\`=@acUser, \`acGroup\`=@acGroup, \`acOther\`=@acOther, \`acRead\`=@acRead, \`acWrite\`=@acWrite, \`acFull\`=@acFull WHERE \`guid\`=UNHEX(@guid);`, {
|
|
1968
|
+
etypes: [etype],
|
|
1969
|
+
params: {
|
|
1970
|
+
user,
|
|
1971
|
+
group,
|
|
1972
|
+
acUser,
|
|
1973
|
+
acGroup,
|
|
1974
|
+
acOther,
|
|
1975
|
+
acRead: acRead && ' ' + acRead.join(' ') + ' ',
|
|
1976
|
+
acWrite: acWrite && ' ' + acWrite.join(' ') + ' ',
|
|
1977
|
+
acFull: acFull && ' ' + acFull.join(' ') + ' ',
|
|
1978
|
+
guid,
|
|
1979
|
+
},
|
|
1980
|
+
}));
|
|
1981
|
+
}
|
|
1909
1982
|
const EntityClass = this.nymph.getEntityClassByEtype(etype);
|
|
1910
|
-
|
|
1911
|
-
let
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1983
|
+
if (only == null || only === 'tokens') {
|
|
1984
|
+
for (let name in sdata) {
|
|
1985
|
+
let tokenString = null;
|
|
1986
|
+
try {
|
|
1987
|
+
tokenString = EntityClass.getFTSText(name, JSON.parse(sdata[name]));
|
|
1988
|
+
}
|
|
1989
|
+
catch (e) {
|
|
1990
|
+
// Ignore error.
|
|
1991
|
+
}
|
|
1992
|
+
if (tokenString != null) {
|
|
1993
|
+
const tokens = this.tokenizer.tokenize(tokenString);
|
|
1994
|
+
while (tokens.length) {
|
|
1995
|
+
const currentTokens = tokens.splice(0, 100);
|
|
1996
|
+
const params = {
|
|
1997
|
+
guid,
|
|
1998
|
+
name,
|
|
1999
|
+
};
|
|
2000
|
+
const values = [];
|
|
2001
|
+
for (let i = 0; i < currentTokens.length; i++) {
|
|
2002
|
+
const token = currentTokens[i];
|
|
2003
|
+
params['token' + i] = token.token;
|
|
2004
|
+
params['position' + i] = token.position;
|
|
2005
|
+
params['stem' + i] = token.stem;
|
|
2006
|
+
values.push('(UNHEX(@guid), @name, @token' +
|
|
2007
|
+
i +
|
|
2008
|
+
', @position' +
|
|
2009
|
+
i +
|
|
2010
|
+
', @stem' +
|
|
2011
|
+
i +
|
|
2012
|
+
')');
|
|
2013
|
+
}
|
|
2014
|
+
promises.push(this.queryRun(`INSERT INTO ${MySQLDriver.escape(`${this.prefix}tokens_${etype}`)} (\`guid\`, \`name\`, \`token\`, \`position\`, \`stem\`) VALUES ${values.join(', ')};`, {
|
|
2015
|
+
etypes: [etype],
|
|
2016
|
+
params,
|
|
2017
|
+
}));
|
|
1939
2018
|
}
|
|
1940
|
-
promises.push(this.queryRun(`INSERT INTO ${MySQLDriver.escape(`${this.prefix}tokens_${etype}`)} (\`guid\`, \`name\`, \`token\`, \`position\`, \`stem\`) VALUES ${values.join(', ')};`, {
|
|
1941
|
-
etypes: [etype],
|
|
1942
|
-
params,
|
|
1943
|
-
}));
|
|
1944
2019
|
}
|
|
1945
2020
|
}
|
|
1946
2021
|
}
|
|
1947
|
-
if (
|
|
2022
|
+
if (only == null) {
|
|
1948
2023
|
const uniques = await EntityClass.getUniques({
|
|
1949
2024
|
guid,
|
|
1950
2025
|
cdate,
|
|
@@ -2164,12 +2239,21 @@ export default class MySQLDriver extends NymphDriver {
|
|
|
2164
2239
|
Object.keys(sdata).length === 0) {
|
|
2165
2240
|
return false;
|
|
2166
2241
|
}
|
|
2167
|
-
|
|
2242
|
+
let { user, group, acUser, acGroup, acOther, acRead, acWrite, acFull, } = this.removeAndReturnACValues(etype, data, sdata);
|
|
2243
|
+
await this.queryRun(`INSERT INTO ${MySQLDriver.escape(`${this.prefix}entities_${etype}`)} (\`guid\`, \`tags\`, \`cdate\`, \`mdate\`, \`user\`, \`group\`, \`acUser\`, \`acGroup\`, \`acOther\`, \`acRead\`, \`acWrite\`, \`acFull\`) VALUES (UNHEX(@guid), @tags, @cdate, @cdate, ${user == null ? '@user' : 'UNHEX(@user)'}, ${group == null ? '@group' : 'UNHEX(@group)'}, @acUser, @acGroup, @acOther, @acRead, @acWrite, @acFull);`, {
|
|
2168
2244
|
etypes: [etype],
|
|
2169
2245
|
params: {
|
|
2170
2246
|
guid,
|
|
2171
2247
|
tags: ' ' + tags.join(' ') + ' ',
|
|
2172
2248
|
cdate,
|
|
2249
|
+
user,
|
|
2250
|
+
group,
|
|
2251
|
+
acUser,
|
|
2252
|
+
acGroup,
|
|
2253
|
+
acOther,
|
|
2254
|
+
acRead: acRead && ' ' + acRead.join(' ') + ' ',
|
|
2255
|
+
acWrite: acWrite && ' ' + acWrite.join(' ') + ' ',
|
|
2256
|
+
acFull: acFull && ' ' + acFull.join(' ') + ' ',
|
|
2173
2257
|
},
|
|
2174
2258
|
});
|
|
2175
2259
|
await insertData(guid, data, sdata, uniques, etype);
|
|
@@ -2179,6 +2263,7 @@ export default class MySQLDriver extends NymphDriver {
|
|
|
2179
2263
|
Object.keys(sdata).length === 0) {
|
|
2180
2264
|
return false;
|
|
2181
2265
|
}
|
|
2266
|
+
let { user, group, acUser, acGroup, acOther, acRead, acWrite, acFull, } = this.removeAndReturnACValues(etype, data, sdata);
|
|
2182
2267
|
if (this.config.rowLocking) {
|
|
2183
2268
|
const promises = [];
|
|
2184
2269
|
promises.push(this.queryRun(`SELECT 1 FROM ${MySQLDriver.escape(`${this.prefix}entities_${etype}`)} WHERE \`guid\`=UNHEX(@guid) GROUP BY 1 FOR UPDATE;`, {
|
|
@@ -2216,11 +2301,19 @@ export default class MySQLDriver extends NymphDriver {
|
|
|
2216
2301
|
if (this.config.tableLocking) {
|
|
2217
2302
|
await this.queryRun(`LOCK TABLES ${MySQLDriver.escape(`${this.prefix}entities_${etype}`)} WRITE, ${MySQLDriver.escape(`${this.prefix}data_${etype}`)} WRITE, ${MySQLDriver.escape(`${this.prefix}references_${etype}`)} WRITE, ${MySQLDriver.escape(`${this.prefix}tokens_${etype}`)} WRITE, ${MySQLDriver.escape(`${this.prefix}uniques_${etype}`)} WRITE;`);
|
|
2218
2303
|
}
|
|
2219
|
-
const info = await this.queryRun(`UPDATE ${MySQLDriver.escape(`${this.prefix}entities_${etype}`)} SET \`tags\`=@tags, \`mdate\`=@mdate WHERE \`guid\`=UNHEX(@guid) AND \`mdate\` <= @emdate;`, {
|
|
2304
|
+
const info = await this.queryRun(`UPDATE ${MySQLDriver.escape(`${this.prefix}entities_${etype}`)} SET \`tags\`=@tags, \`mdate\`=@mdate, \`user\`=${user == null ? '@user' : 'UNHEX(@user)'}, \`group\`=${group == null ? '@group' : 'UNHEX(@group)'}, \`acUser\`=@acUser, \`acGroup\`=@acGroup, \`acOther\`=@acOther, \`acRead\`=@acRead, \`acWrite\`=@acWrite, \`acFull\`=@acFull WHERE \`guid\`=UNHEX(@guid) AND \`mdate\` <= @emdate;`, {
|
|
2220
2305
|
etypes: [etype],
|
|
2221
2306
|
params: {
|
|
2222
2307
|
tags: ' ' + tags.join(' ') + ' ',
|
|
2223
2308
|
mdate,
|
|
2309
|
+
user,
|
|
2310
|
+
group,
|
|
2311
|
+
acUser,
|
|
2312
|
+
acGroup,
|
|
2313
|
+
acOther,
|
|
2314
|
+
acRead: acRead && ' ' + acRead.join(' ') + ' ',
|
|
2315
|
+
acWrite: acWrite && ' ' + acWrite.join(' ') + ' ',
|
|
2316
|
+
acFull: acFull && ' ' + acFull.join(' ') + ' ',
|
|
2224
2317
|
guid,
|
|
2225
2318
|
emdate: isNaN(Number(entity.mdate)) ? 0 : Number(entity.mdate),
|
|
2226
2319
|
},
|
|
@@ -2355,12 +2448,37 @@ export default class MySQLDriver extends NymphDriver {
|
|
|
2355
2448
|
if (!table2 || !table2.table_name) {
|
|
2356
2449
|
return 'tokens';
|
|
2357
2450
|
}
|
|
2451
|
+
const table3 = await this.queryGet('SELECT `table_name` AS `table_name` FROM `information_schema`.`tables` WHERE `table_schema`=@db AND `table_name` LIKE @prefix LIMIT 1;', {
|
|
2452
|
+
params: {
|
|
2453
|
+
db: this.config.database,
|
|
2454
|
+
prefix: this.prefix + 'entities_' + '%',
|
|
2455
|
+
},
|
|
2456
|
+
});
|
|
2457
|
+
if (table3?.name) {
|
|
2458
|
+
const result = await this.queryGet("SELECT 1 AS `exists` FROM `information_schema`.`columns` WHERE `table_schema`=@db AND `table_name`=@table AND `column_name`='user';", {
|
|
2459
|
+
params: {
|
|
2460
|
+
db: this.config.database,
|
|
2461
|
+
table: table3.table_name,
|
|
2462
|
+
},
|
|
2463
|
+
});
|
|
2464
|
+
if (!result?.exists) {
|
|
2465
|
+
return 'tilmeldColumns';
|
|
2466
|
+
}
|
|
2467
|
+
}
|
|
2358
2468
|
return false;
|
|
2359
2469
|
}
|
|
2360
|
-
async liveMigration(
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2470
|
+
async liveMigration(migrationType) {
|
|
2471
|
+
if (migrationType === 'tokenTables') {
|
|
2472
|
+
const etypes = await this.getEtypes();
|
|
2473
|
+
for (let etype of etypes) {
|
|
2474
|
+
await this.createTokensTable(etype);
|
|
2475
|
+
}
|
|
2476
|
+
}
|
|
2477
|
+
else if (migrationType === 'tilmeldColumns') {
|
|
2478
|
+
const etypes = await this.getEtypes();
|
|
2479
|
+
for (let etype of etypes) {
|
|
2480
|
+
await this.addTilmeldColumnsAndIndexes(etype);
|
|
2481
|
+
}
|
|
2364
2482
|
}
|
|
2365
2483
|
}
|
|
2366
2484
|
}
|