@takaro/db 0.1.4 → 0.2.0

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.
@@ -0,0 +1,4 @@
1
+ import { Knex } from 'knex';
2
+ export declare function up(knex: Knex): Promise<void>;
3
+ export declare function down(knex: Knex): Promise<void>;
4
+ //# sourceMappingURL=20250702181214-platform-id-and-pog-indexes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"20250702181214-platform-id-and-pog-indexes.d.ts","sourceRoot":"","sources":["../../../src/migrations/sql/20250702181214-platform-id-and-pog-indexes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,wBAAsB,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAalD;AAED,wBAAsB,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAapD"}
@@ -0,0 +1,27 @@
1
+ export async function up(knex) {
2
+ // Add indexes for platform ID lookups in resolveRef
3
+ await knex.schema.alterTable('players', (table) => {
4
+ table.index(['domain', 'steamId'], 'idx_players_domain_steamid');
5
+ table.index(['domain', 'epicOnlineServicesId'], 'idx_players_domain_epiconlineservicesid');
6
+ table.index(['domain', 'xboxLiveId'], 'idx_players_domain_xboxliveid');
7
+ table.index(['domain', 'platformId'], 'idx_players_domain_platformid');
8
+ });
9
+ // Add composite index for playerOnGameServer findAssociations query
10
+ await knex.schema.alterTable('playerOnGameServer', (table) => {
11
+ table.index(['domain', 'gameId', 'gameServerId'], 'idx_pog_domain_gameid_gameserverid');
12
+ });
13
+ }
14
+ export async function down(knex) {
15
+ // Drop platform ID indexes
16
+ await knex.schema.alterTable('players', (table) => {
17
+ table.dropIndex([], 'idx_players_domain_steamid');
18
+ table.dropIndex([], 'idx_players_domain_epiconlineservicesid');
19
+ table.dropIndex([], 'idx_players_domain_xboxliveid');
20
+ table.dropIndex([], 'idx_players_domain_platformid');
21
+ });
22
+ // Drop playerOnGameServer composite index
23
+ await knex.schema.alterTable('playerOnGameServer', (table) => {
24
+ table.dropIndex([], 'idx_pog_domain_gameid_gameserverid');
25
+ });
26
+ }
27
+ //# sourceMappingURL=20250702181214-platform-id-and-pog-indexes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"20250702181214-platform-id-and-pog-indexes.js","sourceRoot":"","sources":["../../../src/migrations/sql/20250702181214-platform-id-and-pog-indexes.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC,IAAU;IACjC,oDAAoD;IACpD,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;QAChD,KAAK,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,4BAA4B,CAAC,CAAC;QACjE,KAAK,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,sBAAsB,CAAC,EAAE,yCAAyC,CAAC,CAAC;QAC3F,KAAK,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,YAAY,CAAC,EAAE,+BAA+B,CAAC,CAAC;QACvE,KAAK,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,YAAY,CAAC,EAAE,+BAA+B,CAAC,CAAC;IACzE,CAAC,CAAC,CAAC;IAEH,oEAAoE;IACpE,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,KAAK,EAAE,EAAE;QAC3D,KAAK,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,cAAc,CAAC,EAAE,oCAAoC,CAAC,CAAC;IAC1F,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,IAAU;IACnC,2BAA2B;IAC3B,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;QAChD,KAAK,CAAC,SAAS,CAAC,EAAE,EAAE,4BAA4B,CAAC,CAAC;QAClD,KAAK,CAAC,SAAS,CAAC,EAAE,EAAE,yCAAyC,CAAC,CAAC;QAC/D,KAAK,CAAC,SAAS,CAAC,EAAE,EAAE,+BAA+B,CAAC,CAAC;QACrD,KAAK,CAAC,SAAS,CAAC,EAAE,EAAE,+BAA+B,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,0CAA0C;IAC1C,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,KAAK,EAAE,EAAE;QAC3D,KAAK,CAAC,SAAS,CAAC,EAAE,EAAE,oCAAoC,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Knex } from 'knex';
2
+ export declare function up(knex: Knex): Promise<void>;
3
+ export declare function down(knex: Knex): Promise<void>;
4
+ //# sourceMappingURL=20250703175326-add-ip-to-player-on-gameserver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"20250703175326-add-ip-to-player-on-gameserver.d.ts","sourceRoot":"","sources":["../../../src/migrations/sql/20250703175326-add-ip-to-player-on-gameserver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,wBAAsB,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAIlD;AAED,wBAAsB,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAIpD"}
@@ -0,0 +1,11 @@
1
+ export async function up(knex) {
2
+ await knex.schema.alterTable('playerOnGameServer', (table) => {
3
+ table.string('ip').nullable();
4
+ });
5
+ }
6
+ export async function down(knex) {
7
+ await knex.schema.alterTable('playerOnGameServer', (table) => {
8
+ table.dropColumn('ip');
9
+ });
10
+ }
11
+ //# sourceMappingURL=20250703175326-add-ip-to-player-on-gameserver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"20250703175326-add-ip-to-player-on-gameserver.js","sourceRoot":"","sources":["../../../src/migrations/sql/20250703175326-add-ip-to-player-on-gameserver.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC,IAAU;IACjC,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,KAAK,EAAE,EAAE;QAC3D,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,IAAU;IACnC,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,KAAK,EAAE,EAAE;QAC3D,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Knex } from 'knex';
2
+ export declare function up(knex: Knex): Promise<void>;
3
+ export declare function down(knex: Knex): Promise<void>;
4
+ //# sourceMappingURL=20250707205720-items-permissions-missing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"20250707205720-items-permissions-missing.d.ts","sourceRoot":"","sources":["../../../src/migrations/sql/20250707205720-items-permissions-missing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,wBAAsB,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAalD;AAED,wBAAsB,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAEpD"}
@@ -0,0 +1,18 @@
1
+ export async function up(knex) {
2
+ await knex('permission').insert([
3
+ {
4
+ permission: 'READ_ITEMS',
5
+ description: 'Can view item details',
6
+ friendlyName: 'Read Items',
7
+ },
8
+ {
9
+ permission: 'MANAGE_ITEMS',
10
+ description: 'Can create, update, and delete items',
11
+ friendlyName: 'Manage Items',
12
+ },
13
+ ]);
14
+ }
15
+ export async function down(knex) {
16
+ await knex('permission').whereIn('permission', ['READ_ITEMS', 'MANAGE_ITEMS']).del();
17
+ }
18
+ //# sourceMappingURL=20250707205720-items-permissions-missing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"20250707205720-items-permissions-missing.js","sourceRoot":"","sources":["../../../src/migrations/sql/20250707205720-items-permissions-missing.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC,IAAU;IACjC,MAAM,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC;QAC9B;YACE,UAAU,EAAE,YAAY;YACxB,WAAW,EAAE,uBAAuB;YACpC,YAAY,EAAE,YAAY;SAC3B;QACD;YACE,UAAU,EAAE,cAAc;YAC1B,WAAW,EAAE,sCAAsC;YACnD,YAAY,EAAE,cAAc;SAC7B;KACF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,IAAU;IACnC,MAAM,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;AACvF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takaro/db",
3
- "version": "0.1.4",
3
+ "version": "0.2.0",
4
4
  "description": "An opinionated data layer",
5
5
  "main": "dist/main.js",
6
6
  "types": "dist/main.d.ts",
@@ -0,0 +1,31 @@
1
+ import { Knex } from 'knex';
2
+
3
+ export async function up(knex: Knex): Promise<void> {
4
+ // Add indexes for platform ID lookups in resolveRef
5
+ await knex.schema.alterTable('players', (table) => {
6
+ table.index(['domain', 'steamId'], 'idx_players_domain_steamid');
7
+ table.index(['domain', 'epicOnlineServicesId'], 'idx_players_domain_epiconlineservicesid');
8
+ table.index(['domain', 'xboxLiveId'], 'idx_players_domain_xboxliveid');
9
+ table.index(['domain', 'platformId'], 'idx_players_domain_platformid');
10
+ });
11
+
12
+ // Add composite index for playerOnGameServer findAssociations query
13
+ await knex.schema.alterTable('playerOnGameServer', (table) => {
14
+ table.index(['domain', 'gameId', 'gameServerId'], 'idx_pog_domain_gameid_gameserverid');
15
+ });
16
+ }
17
+
18
+ export async function down(knex: Knex): Promise<void> {
19
+ // Drop platform ID indexes
20
+ await knex.schema.alterTable('players', (table) => {
21
+ table.dropIndex([], 'idx_players_domain_steamid');
22
+ table.dropIndex([], 'idx_players_domain_epiconlineservicesid');
23
+ table.dropIndex([], 'idx_players_domain_xboxliveid');
24
+ table.dropIndex([], 'idx_players_domain_platformid');
25
+ });
26
+
27
+ // Drop playerOnGameServer composite index
28
+ await knex.schema.alterTable('playerOnGameServer', (table) => {
29
+ table.dropIndex([], 'idx_pog_domain_gameid_gameserverid');
30
+ });
31
+ }
@@ -0,0 +1,13 @@
1
+ import { Knex } from 'knex';
2
+
3
+ export async function up(knex: Knex): Promise<void> {
4
+ await knex.schema.alterTable('playerOnGameServer', (table) => {
5
+ table.string('ip').nullable();
6
+ });
7
+ }
8
+
9
+ export async function down(knex: Knex): Promise<void> {
10
+ await knex.schema.alterTable('playerOnGameServer', (table) => {
11
+ table.dropColumn('ip');
12
+ });
13
+ }
@@ -0,0 +1,20 @@
1
+ import { Knex } from 'knex';
2
+
3
+ export async function up(knex: Knex): Promise<void> {
4
+ await knex('permission').insert([
5
+ {
6
+ permission: 'READ_ITEMS',
7
+ description: 'Can view item details',
8
+ friendlyName: 'Read Items',
9
+ },
10
+ {
11
+ permission: 'MANAGE_ITEMS',
12
+ description: 'Can create, update, and delete items',
13
+ friendlyName: 'Manage Items',
14
+ },
15
+ ]);
16
+ }
17
+
18
+ export async function down(knex: Knex): Promise<void> {
19
+ await knex('permission').whereIn('permission', ['READ_ITEMS', 'MANAGE_ITEMS']).del();
20
+ }