@hot-updater/postgres 1.0.0-rc.17 → 1.0.0-rc.18

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/index.cjs CHANGED
@@ -30,8 +30,9 @@ pg = __toESM(pg, 1);
30
30
  const { Pool } = pg.default;
31
31
  /**
32
32
  * Hot Updater's database on PostgreSQL, through a `pg` pool or the given
33
- * Kysely dialect. Apply `sql/bundles.sql` before first use; the schema fence
34
- * refuses a database without its settings rows.
33
+ * Kysely dialect. Before first use, apply `sql/bundles.sql`, core's tables,
34
+ * and add the tables of the server's plugins with `hot-updater db migrate`;
35
+ * the schema fence refuses a database without their settings rows.
35
36
  */
36
37
  const postgres = (config) => {
37
38
  const { dialect, ...poolConfig } = config;
package/dist/index.d.cts CHANGED
@@ -7,8 +7,9 @@ type PostgresConfig = PoolConfig & {
7
7
  };
8
8
  /**
9
9
  * Hot Updater's database on PostgreSQL, through a `pg` pool or the given
10
- * Kysely dialect. Apply `sql/bundles.sql` before first use; the schema fence
11
- * refuses a database without its settings rows.
10
+ * Kysely dialect. Before first use, apply `sql/bundles.sql`, core's tables,
11
+ * and add the tables of the server's plugins with `hot-updater db migrate`;
12
+ * the schema fence refuses a database without their settings rows.
12
13
  */
13
14
  declare const postgres: (config: PostgresConfig) => EngineDatabase;
14
15
  //#endregion
package/dist/index.d.mts CHANGED
@@ -7,8 +7,9 @@ type PostgresConfig = PoolConfig & {
7
7
  };
8
8
  /**
9
9
  * Hot Updater's database on PostgreSQL, through a `pg` pool or the given
10
- * Kysely dialect. Apply `sql/bundles.sql` before first use; the schema fence
11
- * refuses a database without its settings rows.
10
+ * Kysely dialect. Before first use, apply `sql/bundles.sql`, core's tables,
11
+ * and add the tables of the server's plugins with `hot-updater db migrate`;
12
+ * the schema fence refuses a database without their settings rows.
12
13
  */
13
14
  declare const postgres: (config: PostgresConfig) => EngineDatabase;
14
15
  //#endregion
package/dist/index.mjs CHANGED
@@ -6,8 +6,9 @@ import pg from "pg";
6
6
  const { Pool } = pg;
7
7
  /**
8
8
  * Hot Updater's database on PostgreSQL, through a `pg` pool or the given
9
- * Kysely dialect. Apply `sql/bundles.sql` before first use; the schema fence
10
- * refuses a database without its settings rows.
9
+ * Kysely dialect. Before first use, apply `sql/bundles.sql`, core's tables,
10
+ * and add the tables of the server's plugins with `hot-updater db migrate`;
11
+ * the schema fence refuses a database without their settings rows.
11
12
  */
12
13
  const postgres = (config) => {
13
14
  const { dialect, ...poolConfig } = config;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hot-updater/postgres",
3
3
  "type": "module",
4
- "version": "1.0.0-rc.17",
4
+ "version": "1.0.0-rc.18",
5
5
  "description": "React Native OTA solution for self-hosted",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.mjs",
@@ -34,9 +34,9 @@
34
34
  "dependencies": {
35
35
  "kysely": "0.28.17",
36
36
  "pg": "8.13.1",
37
- "@hot-updater/plugin-core": "1.0.0-rc.16",
38
37
  "@hot-updater/core": "1.0.0-rc.15",
39
- "@hot-updater/server": "1.0.0-rc.17"
38
+ "@hot-updater/server": "1.0.0-rc.18",
39
+ "@hot-updater/plugin-core": "1.0.0-rc.17"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@electric-sql/pglite": "0.4.1",
@@ -45,7 +45,7 @@
45
45
  "camelcase-keys": "^9.1.3",
46
46
  "kysely-pglite-dialect": "1.2.0",
47
47
  "pg-minify": "^1.6.5",
48
- "@hot-updater/test-utils": "1.0.0-rc.16"
48
+ "@hot-updater/test-utils": "1.0.0-rc.17"
49
49
  },
50
50
  "scripts": {
51
51
  "build": "tsdown",
package/sql/bundles.sql CHANGED
@@ -34,46 +34,8 @@ CREATE UNIQUE INDEX IF NOT EXISTS "channels_name" ON "channels" ("name");
34
34
 
35
35
  CREATE TABLE IF NOT EXISTS "bundle_totals" ("platform_key" varchar(16) COLLATE "C" NOT NULL, "_shard" bigint NOT NULL, "bundles" bigint NOT NULL, "_v" bigint NOT NULL DEFAULT 0, PRIMARY KEY ("platform_key", "_shard"));
36
36
 
37
- CREATE TABLE IF NOT EXISTS "bundle_events" ("id" varchar(36) COLLATE "C" NOT NULL, "type" varchar(32) COLLATE "C" NOT NULL, "install_id" varchar(255) COLLATE "C" NOT NULL, "user_id" varchar(255) COLLATE "C", "from_release_id" varchar(36) COLLATE "C", "from_bundle_id" varchar(36) COLLATE "C", "to_release_id" varchar(36) COLLATE "C", "to_bundle_id" varchar(36) COLLATE "C" NOT NULL, "platform" varchar(16) COLLATE "C" NOT NULL, "app_version" text COLLATE "C" NOT NULL, "channel" text COLLATE "C" NOT NULL, "metadata" jsonb NOT NULL, "received_at_ms" bigint NOT NULL, "day" bigint, "movement_install_id" text COLLATE "C", "bundle_ref" jsonb, "_v" bigint NOT NULL DEFAULT 0, PRIMARY KEY ("id"));
38
-
39
- CREATE INDEX IF NOT EXISTS "bundle_events_recent" ON "bundle_events" ("channel", "platform", "day", "received_at_ms", "id");
40
-
41
- CREATE INDEX IF NOT EXISTS "bundle_events_movementsByInstall" ON "bundle_events" ("movement_install_id", "received_at_ms", "id");
42
-
43
- CREATE TABLE IF NOT EXISTS "bundle_events__byBundle" ("platform" varchar(16) COLLATE "C" NOT NULL, "channel" text COLLATE "C" NOT NULL, "type" varchar(32) COLLATE "C" NOT NULL, "bundle_ref" text COLLATE "C" NOT NULL, "day" bigint NOT NULL, "received_at_ms" bigint NOT NULL, "id" varchar(36) COLLATE "C" NOT NULL, PRIMARY KEY ("platform", "channel", "type", "bundle_ref", "day", "received_at_ms", "id"));
44
-
45
- CREATE INDEX IF NOT EXISTS "bundle_events_byDay" ON "bundle_events" ("day", "received_at_ms", "id");
46
-
47
- CREATE TABLE IF NOT EXISTS "bundle_event_heads" ("install_id" varchar(255) COLLATE "C" NOT NULL, "id" varchar(36) COLLATE "C" NOT NULL, "type" varchar(32) COLLATE "C" NOT NULL, "user_id" varchar(255) COLLATE "C", "from_release_id" varchar(36) COLLATE "C", "from_bundle_id" varchar(36) COLLATE "C", "to_release_id" varchar(36) COLLATE "C", "to_bundle_id" varchar(36) COLLATE "C" NOT NULL, "platform" varchar(16) COLLATE "C" NOT NULL, "app_version" text COLLATE "C" NOT NULL, "channel" text COLLATE "C" NOT NULL, "metadata" jsonb NOT NULL, "received_at_ms" bigint NOT NULL, "current_release_id" varchar(36) COLLATE "C", "_v" bigint NOT NULL DEFAULT 0, PRIMARY KEY ("install_id"));
48
-
49
- CREATE INDEX IF NOT EXISTS "bundle_event_heads_byUser" ON "bundle_event_heads" ("user_id", "install_id");
50
-
51
- CREATE TABLE IF NOT EXISTS "insights_overview" ("identity" varchar(32) COLLATE "C" NOT NULL, "bucket_start_ms" bigint NOT NULL, "_shard" bigint NOT NULL, "downloads" bigint NOT NULL, "launches" bigint NOT NULL, "failed_launches" bigint NOT NULL, "_v" bigint NOT NULL DEFAULT 0, PRIMARY KEY ("identity", "bucket_start_ms", "_shard"));
52
-
53
- CREATE TABLE IF NOT EXISTS "insights_sketches" ("identity" varchar(32) COLLATE "C" NOT NULL, "bucket_start_ms" bigint NOT NULL, "_shard" bigint NOT NULL, "launch_users" text COLLATE "C", "activity_users" text COLLATE "C", "_v" bigint NOT NULL DEFAULT 0, PRIMARY KEY ("identity", "bucket_start_ms", "_shard"));
54
-
55
- CREATE TABLE IF NOT EXISTS "insights_distribution" ("channel" text COLLATE "C" NOT NULL, "platform" varchar(16) COLLATE "C" NOT NULL, "app_version" text COLLATE "C" NOT NULL, "release_id" varchar(36) COLLATE "C" NOT NULL, "bucket_start_ms" bigint NOT NULL, "_shard" bigint NOT NULL, "latest_installations" bigint NOT NULL, "_v" bigint NOT NULL DEFAULT 0, PRIMARY KEY ("channel", "platform", "app_version", "release_id", "bucket_start_ms", "_shard"));
56
-
57
- CREATE INDEX IF NOT EXISTS "insights_distribution_byScope" ON "insights_distribution" ("channel", "platform", "bucket_start_ms", "app_version", "release_id", "_shard");
58
-
59
- CREATE INDEX IF NOT EXISTS "insights_distribution_byVersion" ON "insights_distribution" ("channel", "platform", "app_version", "bucket_start_ms", "release_id", "_shard");
60
-
61
- CREATE TABLE IF NOT EXISTS "insights_latest_by_bundle" ("platform" varchar(16) COLLATE "C" NOT NULL, "channel" text COLLATE "C" NOT NULL, "bundle_field" varchar(16) COLLATE "C" NOT NULL, "bundle_id" varchar(36) COLLATE "C" NOT NULL, "type" varchar(32) COLLATE "C" NOT NULL, "bucket_start_ms" bigint NOT NULL, "_shard" bigint NOT NULL, "installations" bigint NOT NULL, "_v" bigint NOT NULL DEFAULT 0, PRIMARY KEY ("platform", "channel", "bundle_field", "bundle_id", "type", "bucket_start_ms", "_shard"));
62
-
63
- CREATE TABLE IF NOT EXISTS "insights_outcomes" ("platform" varchar(16) COLLATE "C" NOT NULL, "channel" text COLLATE "C" NOT NULL, "type" varchar(32) COLLATE "C" NOT NULL, "bundle_ref" varchar(41) COLLATE "C" NOT NULL, "bucket_start_ms" bigint NOT NULL, "_shard" bigint NOT NULL, "events" bigint NOT NULL, "_v" bigint NOT NULL DEFAULT 0, PRIMARY KEY ("platform", "channel", "type", "bundle_ref", "bucket_start_ms", "_shard"));
64
-
65
- CREATE TABLE IF NOT EXISTS "api_keys" ("id" varchar(255) COLLATE "C" NOT NULL, "hash" varchar(64) COLLATE "C" NOT NULL, "name" varchar(64) COLLATE "C" NOT NULL, "prefix" varchar(16) COLLATE "C" NOT NULL, "role" varchar(16) COLLATE "C" NOT NULL, "created_at_ms" bigint NOT NULL, "revoked_at_ms" bigint, "_v" bigint NOT NULL DEFAULT 0, PRIMARY KEY ("id"));
66
-
67
- CREATE INDEX IF NOT EXISTS "api_keys_byCreated" ON "api_keys" ("created_at_ms", "id");
68
-
69
- CREATE UNIQUE INDEX IF NOT EXISTS "api_keys_hash" ON "api_keys" ("hash");
70
-
71
37
  CREATE TABLE IF NOT EXISTS "private_hot_updater_settings" ("key" varchar(255) COLLATE "C" NOT NULL, "value" varchar(255) COLLATE "C" NOT NULL, "_v" bigint NOT NULL DEFAULT 0, PRIMARY KEY ("key"));
72
38
 
73
39
  INSERT INTO "private_hot_updater_settings" ("key", "value", "_v") VALUES ('schema.engine', '1', 0) ON CONFLICT ("key") DO UPDATE SET "value" = excluded."value";
74
40
 
75
41
  INSERT INTO "private_hot_updater_settings" ("key", "value", "_v") VALUES ('schema.core', '1.0.0', 0) ON CONFLICT ("key") DO UPDATE SET "value" = excluded."value";
76
-
77
- INSERT INTO "private_hot_updater_settings" ("key", "value", "_v") VALUES ('schema.insights', '1.0.0', 0) ON CONFLICT ("key") DO UPDATE SET "value" = excluded."value";
78
-
79
- INSERT INTO "private_hot_updater_settings" ("key", "value", "_v") VALUES ('schema.apiKeys', '1.0.0', 0) ON CONFLICT ("key") DO UPDATE SET "value" = excluded."value";