@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.
@@ -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,2 +1 @@
1
- export * from './passwords';
2
1
  export * from './traits';
@@ -1,2 +1 @@
1
- export * from "./passwords";
2
1
  export * from "./traits";
@@ -1,33 +1,19 @@
1
- // bun-query-builder utilities are used via db.unsafe() for raw SQL
2
- export declare function getTraitTables(): string[];
3
- // SQLite/MySQL version
4
- export declare function createPasskeyMigration(): Promise<void>;
5
- // PostgreSQL version
6
- export declare function createPostgresPasskeyMigration(): Promise<void>;
7
- export declare function createTaggableTable(): Promise<void>;
8
- export declare function createPostgresTagsTable(): Promise<void>;
9
- // SQLite/MySQL version
10
- export declare function createCategorizableTable(): Promise<void>;
11
- // PostgreSQL version
12
- export declare function createPostgresCategorizableTable(): Promise<void>;
13
- // SQLite/MySQL version
14
- export declare function createCommentablesTable(options?: {
15
- requiresApproval?: boolean
16
- reportable?: boolean
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
- export declare function truncateMigrationTables(): Promise<void>;
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>;