Skip to content

Commit

Permalink
chore(insight): upgrade versions (#7092)
Browse files Browse the repository at this point in the history
* chore(insight): upgrade versions

* chore(insights): upgrade drizzel version

* chare(insights): add DB indexes
  • Loading branch information
mhevery authored Nov 28, 2024
1 parent ef22a18 commit f7dc3ef
Show file tree
Hide file tree
Showing 26 changed files with 2,840 additions and 1,043 deletions.
38 changes: 20 additions & 18 deletions packages/insights/drizzle.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,23 @@ export const PRIVATE_LIBSQL_DB_URL = process.env.PRIVATE_LIBSQL_DB_URL!;
export const PRIVATE_LIBSQL_DB_API_TOKEN = process.env.PRIVATE_LIBSQL_DB_API_TOKEN!;
const isLocalDB = PRIVATE_LIBSQL_DB_URL.startsWith('ws://');

export default (isLocalDB
? {
schema: './src/db/schema.ts',
out: './drizzle',
driver: 'libsql',
dbCredentials: {
url: PRIVATE_LIBSQL_DB_URL,
},
}
: {
schema: './src/db/schema.ts',
out: './drizzle',
driver: 'turso',
dbCredentials: {
url: PRIVATE_LIBSQL_DB_URL,
authToken: PRIVATE_LIBSQL_DB_API_TOKEN,
},
}) satisfies Config;
const local: Config = {
schema: './src/db/schema.ts',
out: './drizzle',
dialect: 'sqlite',
dbCredentials: {
url: PRIVATE_LIBSQL_DB_URL,
},
};

const prod: Config = {
schema: './src/db/schema.ts',
out: './drizzle',
dialect: 'turso',
dbCredentials: {
url: PRIVATE_LIBSQL_DB_URL,
authToken: PRIVATE_LIBSQL_DB_API_TOKEN,
},
};
console.log('Drizzle config:', isLocalDB ? 'local' : 'prod');
export default isLocalDB ? local : prod;
10 changes: 10 additions & 0 deletions packages/insights/drizzle/0016_demonic_legion.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
DROP INDEX IF EXISTS `edgeIndex_PublicApiKey_manifestHash`;--> statement-breakpoint
DROP INDEX IF EXISTS `edgeIndex`;--> statement-breakpoint
CREATE INDEX `idx_edge_publicApiKey_manifestHash` ON `edges` (`public_api_key`,`manifest_hash`);--> statement-breakpoint
CREATE INDEX `idx_edge_apiKey_manifestHash_from_to` ON `edges` (`public_api_key`,`manifest_hash`,`from`,`to`);--> statement-breakpoint
DROP INDEX IF EXISTS `hashIndex`;--> statement-breakpoint
CREATE UNIQUE INDEX `idx_manifests_apiKey_hash` ON `manifests` (`hash`,`public_api_key`);--> statement-breakpoint
CREATE INDEX `idx_manifests_public_apiKey` ON `manifests` (`public_api_key`);--> statement-breakpoint
CREATE INDEX `idx_manifests_hash` ON `manifests` (`hash`);--> statement-breakpoint
CREATE INDEX `idx_routes_publicApiKey_manifestHash` ON `routes` (`public_api_key`,`manifest_hash`);--> statement-breakpoint
CREATE UNIQUE INDEX `idx_symbolDetail_apiKey_manifestHash` ON `symbolDetail` (`public_api_key`,`manifest_hash`);
24 changes: 14 additions & 10 deletions packages/insights/drizzle/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"version": "5",
"version": "6",
"dialect": "sqlite",
"id": "15fea7b6-cecc-4cf7-9f8e-18393db5b9cc",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"applications": {
"name": "applications",
Expand Down Expand Up @@ -46,7 +44,9 @@
}
},
"foreignKeys": {},
"compositePrimaryKeys": {}
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"symbols": {
"name": "symbols",
Expand Down Expand Up @@ -113,24 +113,28 @@
"symbols_public_api_key_applications_public_api_key_fk": {
"name": "symbols_public_api_key_applications_public_api_key_fk",
"tableFrom": "symbols",
"tableTo": "applications",
"columnsFrom": [
"public_api_key"
],
"tableTo": "applications",
"columnsTo": [
"public_api_key"
],
"onDelete": "no action",
"onUpdate": "no action"
"onUpdate": "no action",
"onDelete": "no action"
}
},
"compositePrimaryKeys": {}
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
}
},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
}
},
"id": "15fea7b6-cecc-4cf7-9f8e-18393db5b9cc",
"prevId": "00000000-0000-0000-0000-000000000000",
"views": {}
}
24 changes: 14 additions & 10 deletions packages/insights/drizzle/meta/0001_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"version": "5",
"version": "6",
"dialect": "sqlite",
"id": "cb985a7f-25e8-41bc-9215-c28801dfe4e1",
"prevId": "15fea7b6-cecc-4cf7-9f8e-18393db5b9cc",
"tables": {
"applications": {
"name": "applications",
Expand Down Expand Up @@ -46,7 +44,9 @@
}
},
"foreignKeys": {},
"compositePrimaryKeys": {}
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"symbols": {
"name": "symbols",
Expand Down Expand Up @@ -120,24 +120,28 @@
"symbols_public_api_key_applications_public_api_key_fk": {
"name": "symbols_public_api_key_applications_public_api_key_fk",
"tableFrom": "symbols",
"tableTo": "applications",
"columnsFrom": [
"public_api_key"
],
"tableTo": "applications",
"columnsTo": [
"public_api_key"
],
"onDelete": "no action",
"onUpdate": "no action"
"onUpdate": "no action",
"onDelete": "no action"
}
},
"compositePrimaryKeys": {}
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
}
},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
}
},
"id": "cb985a7f-25e8-41bc-9215-c28801dfe4e1",
"prevId": "15fea7b6-cecc-4cf7-9f8e-18393db5b9cc",
"views": {}
}
34 changes: 20 additions & 14 deletions packages/insights/drizzle/meta/0002_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"version": "5",
"version": "6",
"dialect": "sqlite",
"id": "6dc81006-f64d-4f8b-8d1a-0853e9e111f8",
"prevId": "cb985a7f-25e8-41bc-9215-c28801dfe4e1",
"tables": {
"applications": {
"name": "applications",
Expand Down Expand Up @@ -46,7 +44,9 @@
}
},
"foreignKeys": {},
"compositePrimaryKeys": {}
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"errors": {
"name": "errors",
Expand Down Expand Up @@ -127,18 +127,20 @@
"errors_public_api_key_applications_public_api_key_fk": {
"name": "errors_public_api_key_applications_public_api_key_fk",
"tableFrom": "errors",
"tableTo": "applications",
"columnsFrom": [
"public_api_key"
],
"tableTo": "applications",
"columnsTo": [
"public_api_key"
],
"onDelete": "no action",
"onUpdate": "no action"
"onUpdate": "no action",
"onDelete": "no action"
}
},
"compositePrimaryKeys": {}
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"symbols": {
"name": "symbols",
Expand Down Expand Up @@ -212,24 +214,28 @@
"symbols_public_api_key_applications_public_api_key_fk": {
"name": "symbols_public_api_key_applications_public_api_key_fk",
"tableFrom": "symbols",
"tableTo": "applications",
"columnsFrom": [
"public_api_key"
],
"tableTo": "applications",
"columnsTo": [
"public_api_key"
],
"onDelete": "no action",
"onUpdate": "no action"
"onUpdate": "no action",
"onDelete": "no action"
}
},
"compositePrimaryKeys": {}
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
}
},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
}
},
"id": "6dc81006-f64d-4f8b-8d1a-0853e9e111f8",
"prevId": "cb985a7f-25e8-41bc-9215-c28801dfe4e1",
"views": {}
}
34 changes: 20 additions & 14 deletions packages/insights/drizzle/meta/0003_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"version": "5",
"version": "6",
"dialect": "sqlite",
"id": "3f1754dc-7635-4f8f-bfa7-c4c6e500959a",
"prevId": "6dc81006-f64d-4f8b-8d1a-0853e9e111f8",
"tables": {
"applications": {
"name": "applications",
Expand Down Expand Up @@ -46,7 +44,9 @@
}
},
"foreignKeys": {},
"compositePrimaryKeys": {}
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"errors": {
"name": "errors",
Expand Down Expand Up @@ -134,18 +134,20 @@
"errors_public_api_key_applications_public_api_key_fk": {
"name": "errors_public_api_key_applications_public_api_key_fk",
"tableFrom": "errors",
"tableTo": "applications",
"columnsFrom": [
"public_api_key"
],
"tableTo": "applications",
"columnsTo": [
"public_api_key"
],
"onDelete": "no action",
"onUpdate": "no action"
"onUpdate": "no action",
"onDelete": "no action"
}
},
"compositePrimaryKeys": {}
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"symbols": {
"name": "symbols",
Expand Down Expand Up @@ -219,24 +221,28 @@
"symbols_public_api_key_applications_public_api_key_fk": {
"name": "symbols_public_api_key_applications_public_api_key_fk",
"tableFrom": "symbols",
"tableTo": "applications",
"columnsFrom": [
"public_api_key"
],
"tableTo": "applications",
"columnsTo": [
"public_api_key"
],
"onDelete": "no action",
"onUpdate": "no action"
"onUpdate": "no action",
"onDelete": "no action"
}
},
"compositePrimaryKeys": {}
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
}
},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
}
},
"id": "3f1754dc-7635-4f8f-bfa7-c4c6e500959a",
"prevId": "6dc81006-f64d-4f8b-8d1a-0853e9e111f8",
"views": {}
}
Loading

0 comments on commit f7dc3ef

Please sign in to comment.