@mikro-orm/sql 7.3.0-dev.15 → 7.3.0-dev.16
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/dialects/mysql/MySqlSchemaHelper.d.ts +4 -0
- package/dialects/mysql/MySqlSchemaHelper.js +5 -0
- package/dialects/postgresql/PostgreSqlSchemaHelper.d.ts +4 -0
- package/dialects/postgresql/PostgreSqlSchemaHelper.js +7 -0
- package/package.json +2 -2
- package/schema/SchemaHelper.d.ts +9 -0
- package/schema/SchemaHelper.js +8 -0
|
@@ -16,6 +16,10 @@ export declare class MySqlSchemaHelper extends SchemaHelper {
|
|
|
16
16
|
getSchemaBeginning(charset: string, disableForeignKeys?: boolean): string;
|
|
17
17
|
getSetSchemaSQL(schema: string): string;
|
|
18
18
|
getResetSchemaSQL(defaultSchema: string): string;
|
|
19
|
+
getMigrationLockSQL(): {
|
|
20
|
+
acquire: string;
|
|
21
|
+
release: string;
|
|
22
|
+
};
|
|
19
23
|
supportsMigrationSchema(): boolean;
|
|
20
24
|
tableExists(connection: AbstractSqlConnection, tableName: string, schemaName: string | undefined, ctx?: Transaction): Promise<boolean>;
|
|
21
25
|
disableForeignKeysSQL(): string;
|
|
@@ -24,6 +24,11 @@ export class MySqlSchemaHelper extends SchemaHelper {
|
|
|
24
24
|
getResetSchemaSQL(defaultSchema) {
|
|
25
25
|
return `use ${this.quote(defaultSchema)}`;
|
|
26
26
|
}
|
|
27
|
+
getMigrationLockSQL() {
|
|
28
|
+
// `get_lock` names are server-wide and limited to 64 characters
|
|
29
|
+
const name = `left(concat(database(), '.', ?), 64)`;
|
|
30
|
+
return { acquire: `select get_lock(${name}, 0) as locked`, release: `select release_lock(${name})` };
|
|
31
|
+
}
|
|
27
32
|
supportsMigrationSchema() {
|
|
28
33
|
return true;
|
|
29
34
|
}
|
|
@@ -19,6 +19,10 @@ export declare class PostgreSqlSchemaHelper extends SchemaHelper {
|
|
|
19
19
|
getSchemaBeginning(charset: string, disableForeignKeys?: boolean): string;
|
|
20
20
|
getSetSchemaSQL(schema: string): string;
|
|
21
21
|
getResetSchemaSQL(_defaultSchema: string): string;
|
|
22
|
+
getMigrationLockSQL(): {
|
|
23
|
+
acquire: string;
|
|
24
|
+
release: string;
|
|
25
|
+
} | undefined;
|
|
22
26
|
supportsMigrationSchema(): boolean;
|
|
23
27
|
getCreateDatabaseSQL(name: string): string;
|
|
24
28
|
getListTablesSQL(): string;
|
|
@@ -33,6 +33,13 @@ export class PostgreSqlSchemaHelper extends SchemaHelper {
|
|
|
33
33
|
getResetSchemaSQL(_defaultSchema) {
|
|
34
34
|
return 'reset search_path';
|
|
35
35
|
}
|
|
36
|
+
getMigrationLockSQL() {
|
|
37
|
+
// advisory locks are scoped to the current database
|
|
38
|
+
return {
|
|
39
|
+
acquire: 'select pg_try_advisory_lock(hashtext(?)) as locked',
|
|
40
|
+
release: 'select pg_advisory_unlock(hashtext(?))',
|
|
41
|
+
};
|
|
42
|
+
}
|
|
36
43
|
supportsMigrationSchema() {
|
|
37
44
|
return true;
|
|
38
45
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/sql",
|
|
3
|
-
"version": "7.3.0-dev.
|
|
3
|
+
"version": "7.3.0-dev.16",
|
|
4
4
|
"description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"data-mapper",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@mikro-orm/core": "^7.2.3"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@mikro-orm/core": "7.3.0-dev.
|
|
56
|
+
"@mikro-orm/core": "7.3.0-dev.16"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">= 22.17.0"
|
package/schema/SchemaHelper.d.ts
CHANGED
|
@@ -41,6 +41,15 @@ export declare abstract class SchemaHelper {
|
|
|
41
41
|
supportsMigrationSchema(): boolean;
|
|
42
42
|
/** Restores the session's schema to the connection's default after a migration. */
|
|
43
43
|
getResetSchemaSQL(_defaultSchema: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* Returns the SQL to try taking (without waiting) and to release the session-level lock serializing migration runs,
|
|
46
|
+
* with `name` bound as the only parameter. The try query returns a truthy `locked` column when the lock was taken.
|
|
47
|
+
* `undefined` means the driver has no lock primitive and runs are not serialized.
|
|
48
|
+
*/
|
|
49
|
+
getMigrationLockSQL(): {
|
|
50
|
+
acquire: string;
|
|
51
|
+
release: string;
|
|
52
|
+
} | undefined;
|
|
44
53
|
/** Returns `undefined` for schemaless drivers, throws for drivers that have schemas but no session switch. */
|
|
45
54
|
resolveMigrationSchema(schema: string | undefined): string | undefined;
|
|
46
55
|
finalizeTable(table: DatabaseTable, charset: string, collate?: string): string;
|
package/schema/SchemaHelper.js
CHANGED
|
@@ -71,6 +71,14 @@ export class SchemaHelper {
|
|
|
71
71
|
getResetSchemaSQL(_defaultSchema) {
|
|
72
72
|
return '';
|
|
73
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Returns the SQL to try taking (without waiting) and to release the session-level lock serializing migration runs,
|
|
76
|
+
* with `name` bound as the only parameter. The try query returns a truthy `locked` column when the lock was taken.
|
|
77
|
+
* `undefined` means the driver has no lock primitive and runs are not serialized.
|
|
78
|
+
*/
|
|
79
|
+
getMigrationLockSQL() {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
74
82
|
/** Returns `undefined` for schemaless drivers, throws for drivers that have schemas but no session switch. */
|
|
75
83
|
resolveMigrationSchema(schema) {
|
|
76
84
|
if (!schema) {
|