@stacksjs/database 0.70.256 → 0.70.258
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/dist/auth-tables.js +12 -12
- package/dist/database.js +2 -1
- package/dist/datetime-columns.d.ts +36 -0
- package/dist/datetime-columns.js +85 -0
- package/dist/ddl-constraints.d.ts +31 -0
- package/dist/ddl-constraints.js +111 -0
- package/dist/dialect.d.ts +82 -0
- package/dist/dialect.js +79 -0
- package/dist/driver-config.d.ts +55 -5
- package/dist/driver-config.js +28 -0
- package/dist/drivers/defaults/index.d.ts +0 -1
- package/dist/drivers/defaults/index.js +0 -1
- package/dist/drivers/defaults/traits.d.ts +17 -31
- package/dist/drivers/defaults/traits.js +18 -1142
- package/dist/drivers/mysql.d.ts +0 -1
- package/dist/drivers/mysql.js +1 -14
- package/dist/drivers/postgres.d.ts +0 -1
- package/dist/drivers/postgres.js +2 -35
- package/dist/index.d.ts +20 -0
- package/dist/index.js +6 -0
- package/dist/notification-tables.js +6 -6
- package/dist/query-logger.js +2 -1
- package/dist/rbac-tables.d.ts +3 -3
- package/dist/rbac-tables.js +16 -13
- package/dist/replicas.d.ts +52 -0
- package/dist/replicas.js +74 -0
- package/dist/schema.d.ts +1 -0
- package/dist/sql-helpers.d.ts +60 -7
- package/dist/sql-helpers.js +31 -5
- package/dist/trait-tables.d.ts +126 -0
- package/dist/trait-tables.js +206 -0
- package/dist/utils.d.ts +33 -0
- package/dist/utils.js +102 -13
- package/dist/vschema.d.ts +84 -0
- package/dist/vschema.js +121 -0
- package/package.json +11 -11
- package/dist/drivers/defaults/passwords.d.ts +0 -4
- package/dist/drivers/defaults/passwords.js +0 -106
package/dist/driver-config.js
CHANGED
|
@@ -24,6 +24,15 @@ export const driverDefaults = {
|
|
|
24
24
|
charset: "utf8mb4",
|
|
25
25
|
ssl: !1
|
|
26
26
|
},
|
|
27
|
+
vitess: {
|
|
28
|
+
name: "stacks",
|
|
29
|
+
host: "127.0.0.1",
|
|
30
|
+
port: 15306,
|
|
31
|
+
username: "root",
|
|
32
|
+
password: "",
|
|
33
|
+
prefix: "",
|
|
34
|
+
ssl: !1
|
|
35
|
+
},
|
|
27
36
|
postgres: {
|
|
28
37
|
name: "stacks",
|
|
29
38
|
host: "127.0.0.1",
|
|
@@ -51,6 +60,10 @@ export function getConnectionString(driver, config) {
|
|
|
51
60
|
const ssConfig = config, { name, host = "127.0.0.1", port = 3306, username = "root", password = "" } = ssConfig;
|
|
52
61
|
return `mysql://${username}:${password}@${host}:${port}/${name}`;
|
|
53
62
|
}
|
|
63
|
+
case "vitess": {
|
|
64
|
+
const vtConfig = config, { name, host = "127.0.0.1", port = 15306, username = "root", password = "", tabletType } = vtConfig, keyspace = tabletType ? `${name}@${tabletType}` : name;
|
|
65
|
+
return `mysql://${username}:${password}@${host}:${port}/${keyspace}`;
|
|
66
|
+
}
|
|
54
67
|
case "postgres": {
|
|
55
68
|
const pgConfig = config, { name, host = "127.0.0.1", port = 5432, username = "postgres", password = "" } = pgConfig;
|
|
56
69
|
return `postgres://${username}:${password}@${host}:${port}/${name}`;
|
|
@@ -77,6 +90,11 @@ export function validateDriverConfig(driver, config) {
|
|
|
77
90
|
errors.push("SingleStore requires a database name");
|
|
78
91
|
break;
|
|
79
92
|
}
|
|
93
|
+
case "vitess": {
|
|
94
|
+
if (!config.name)
|
|
95
|
+
errors.push("Vitess requires a keyspace name");
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
80
98
|
case "postgres": {
|
|
81
99
|
if (!config.name)
|
|
82
100
|
errors.push("PostgreSQL requires a database name");
|
|
@@ -119,6 +137,16 @@ export function getConfigFromEnv(driver) {
|
|
|
119
137
|
prefix: env.DB_PREFIX || "",
|
|
120
138
|
ssl: env.DB_SSL === "true" || env.DB_SSL === "1"
|
|
121
139
|
};
|
|
140
|
+
case "vitess":
|
|
141
|
+
return {
|
|
142
|
+
name: env.DB_DATABASE || "stacks",
|
|
143
|
+
host: env.DB_HOST || "127.0.0.1",
|
|
144
|
+
port: env.DB_PORT ?? 15306,
|
|
145
|
+
username: env.DB_USERNAME || "root",
|
|
146
|
+
password: env.DB_PASSWORD || "",
|
|
147
|
+
prefix: env.DB_PREFIX || "",
|
|
148
|
+
ssl: env.DB_SSL === "true" || env.DB_SSL === "1"
|
|
149
|
+
};
|
|
122
150
|
case "postgres":
|
|
123
151
|
return {
|
|
124
152
|
name: env.DB_DATABASE || "stacks",
|
|
@@ -1,33 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
votable?: boolean
|
|
18
|
-
requiresAuth?: boolean
|
|
19
|
-
}): Promise<void>;
|
|
20
|
-
// PostgreSQL version
|
|
21
|
-
export declare function createPostgresCommentsTable(): Promise<void>;
|
|
1
|
+
/**
|
|
2
|
+
* Every framework-owned table a database reset must drop on top of the
|
|
3
|
+
* model-derived ones.
|
|
4
|
+
*
|
|
5
|
+
* Single source of truth on purpose: this list used to be duplicated between
|
|
6
|
+
* `dropCommonTables()` (MySQL + SQLite) and a `dropCommonPostgresTables()` in
|
|
7
|
+
* the Postgres driver, and the two had drifted — the Postgres copy never
|
|
8
|
+
* dropped `categorizable_models`, `categories_models` or `activities`, so
|
|
9
|
+
* `migrate:fresh` on Postgres left them behind with stale rows.
|
|
10
|
+
*/
|
|
11
|
+
export declare function commonTableNames(): string[];
|
|
12
|
+
/**
|
|
13
|
+
* Drop the framework-owned tables. Dialect-aware: Postgres needs `CASCADE` to
|
|
14
|
+
* clear dependent foreign keys, and each dialect quotes identifiers its own
|
|
15
|
+
* way. Every name here is a hard-coded literal, never user input.
|
|
16
|
+
*/
|
|
22
17
|
export declare function dropCommonTables(): Promise<void>;
|
|
23
|
-
|
|
18
|
+
/** Drop the migration ledger tables, so the next migrate starts from zero. */
|
|
24
19
|
export declare function dropMigrationTables(): Promise<void>;
|
|
25
|
-
export declare function createCommentUpvoteMigration(): Promise<void>;
|
|
26
|
-
export declare function createPostgresCommentUpvoteMigration(): Promise<void>;
|
|
27
|
-
export declare function createCommentablesPivotTable(): Promise<void>;
|
|
28
|
-
export declare function createPostgresCommentablesPivotTable(): Promise<void>;
|
|
29
|
-
export declare function createTaggablesTable(): Promise<void>;
|
|
30
|
-
export declare function createPostgresTaggablesTable(): Promise<void>;
|
|
31
|
-
export declare function createQueryLogsTable(): Promise<void>;
|
|
32
|
-
// PostgreSQL version
|
|
33
|
-
export declare function createPostgresQueryLogsTable(): Promise<void>;
|