@kaeawc/auto-mobile 0.0.11 → 0.0.12
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.
|
@@ -1,30 +1,43 @@
|
|
|
1
1
|
import type { Kysely } from "kysely";
|
|
2
|
+
import { sql } from "kysely";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
.execute();
|
|
4
|
+
async function columnExists(
|
|
5
|
+
db: Kysely<unknown>,
|
|
6
|
+
tableName: string,
|
|
7
|
+
columnName: string
|
|
8
|
+
): Promise<boolean> {
|
|
9
|
+
const result = await sql<{ name: string }>`
|
|
10
|
+
SELECT name FROM pragma_table_info(${tableName}) WHERE name = ${columnName}
|
|
11
|
+
`.execute(db);
|
|
12
|
+
return result.rows.length > 0;
|
|
13
|
+
}
|
|
14
14
|
|
|
15
|
+
async function addColumnIfNotExists(
|
|
16
|
+
db: Kysely<unknown>,
|
|
17
|
+
tableName: string,
|
|
18
|
+
columnName: string,
|
|
19
|
+
columnType: string
|
|
20
|
+
): Promise<void> {
|
|
21
|
+
if (await columnExists(db, tableName, columnName)) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
15
24
|
await db.schema
|
|
16
|
-
.alterTable(
|
|
17
|
-
.addColumn(
|
|
25
|
+
.alterTable(tableName)
|
|
26
|
+
.addColumn(columnName, columnType)
|
|
18
27
|
.execute();
|
|
28
|
+
}
|
|
19
29
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
30
|
+
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
31
|
+
// Add new columns to performance_audit_results table for live metrics
|
|
32
|
+
await addColumnIfNotExists(db, "performance_audit_results", "time_to_first_frame_ms", "real");
|
|
33
|
+
await addColumnIfNotExists(db, "performance_audit_results", "time_to_interactive_ms", "real");
|
|
34
|
+
await addColumnIfNotExists(db, "performance_audit_results", "frame_rate_fps", "real");
|
|
35
|
+
await addColumnIfNotExists(db, "performance_audit_results", "node_id", "integer");
|
|
24
36
|
|
|
25
37
|
// Create index on node_id for navigation node lookups
|
|
26
38
|
await db.schema
|
|
27
39
|
.createIndex("idx_performance_audit_results_node_id")
|
|
40
|
+
.ifNotExists()
|
|
28
41
|
.on("performance_audit_results")
|
|
29
42
|
.column("node_id")
|
|
30
43
|
.execute();
|
|
@@ -32,6 +45,7 @@ export async function up(db: Kysely<unknown>): Promise<void> {
|
|
|
32
45
|
// Create composite index on (package_name, timestamp) for efficient pruning
|
|
33
46
|
await db.schema
|
|
34
47
|
.createIndex("idx_performance_audit_results_package_timestamp")
|
|
48
|
+
.ifNotExists()
|
|
35
49
|
.on("performance_audit_results")
|
|
36
50
|
.columns(["package_name", "timestamp"])
|
|
37
51
|
.execute();
|