Skip to content

Commit

Permalink
Skip kysely type generation when migrations are not in use
Browse files Browse the repository at this point in the history
  • Loading branch information
thdxr committed May 31, 2022
1 parent 936c19b commit fa1bea7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 24 deletions.
5 changes: 5 additions & 0 deletions .changeset/neat-ligers-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@serverless-stack/core": patch
---

Skip Kysely type generation when migrations are not in use
26 changes: 2 additions & 24 deletions packages/core/src/cli/KyselyTypeGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export function createKyselyTypeGenerator(opts: Opts) {
opts.bus.subscribe("metadata.updated", metadata => {
databases = metadata.properties
.filter(c => c.type === "RDS")
.filter(c => c.data.migrator)
.filter(c => c.data.types)
.map(c => ({
migratorID: metadata.properties.find(
fn => fn.addr == c.data.migrator?.node
Expand All @@ -43,18 +45,6 @@ export function createKyselyTypeGenerator(opts: Opts) {
if (!db.types) return;
if (evt.properties.request.event.type !== "to") return;

// Trigger typegen
/*
* "clusterArn": "arn:aws:rds:us-east-1:280826753141:cluster:thdxr2-my-sst-app-rds",
"defaultDatabaseName": "mysstapp",
"engine": "postgresql10.14",
"secretArn": "arn:aws:secretsmanager:us-east-1:280826753141:secret:rdsClusterSecret694AB211-ZOby5iWPpyac-c6vwdV",
"migrator": {
"node": "c84162f63d6ed8a85a6e0614421d03c5f5f3718a47",
"stack": "thdxr2-my-sst-app-Database"
},
"clusterIdentifier": "thdxr2-my-sst-app-rds"
*/
const k = knex({
client: knexDataAPiClient.postgres,
connection: {
Expand All @@ -65,18 +55,6 @@ export function createKyselyTypeGenerator(opts: Opts) {
} as any
});

console.log(
JSON.stringify(
await toObject(
{
interfaceNameFormat: "${table}"
},
k as any
),
null,
4
)
);
const result = await toTypeScript(
{
interfaceNameFormat: "${table}"
Expand Down

0 comments on commit fa1bea7

Please sign in to comment.