Skip to content

Commit

Permalink
examples: Linearlite load initial data (#1987)
Browse files Browse the repository at this point in the history
load initial data in Linearlite example
  • Loading branch information
balegas authored Nov 18, 2024
1 parent 91e5b85 commit f1e7d70
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
14 changes: 14 additions & 0 deletions examples/linearlite/sst.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ export default $config({

const db = new neon.Database(`linearlite`, {
...base,
name:
$app.stage === `Production`
? `linearlite-production`
: `linearlite-${$app.stage}`,
ownerName: `neondb_owner`,
})

const databaseUri = getNeonDbUri(project, db)
try {
databaseUri.apply(applyMigrations)
databaseUri.apply(loadData)

const electricInfo = databaseUri.apply((uri) =>
addDatabaseToElectric(uri)
Expand Down Expand Up @@ -60,6 +65,15 @@ function applyMigrations(uri: string) {
})
}

function loadData(uri: string) {
execSync(`pnpm run db:load-data`, {
env: {
...process.env,
DATABASE_URL: uri,
},
})
}

function deployLinearLite(
electricInfo: $util.Output<{ id: string; token: string }>
) {
Expand Down
4 changes: 4 additions & 0 deletions examples/nextjs-example/sst-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@ import "sst"
export {}
declare module "sst" {
export interface Resource {
"nextjs": {
"type": "sst.aws.Nextjs"
"url": string
}
}
}
2 changes: 1 addition & 1 deletion examples/nextjs-example/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
"exclude": ["node_modules", "sst.config.ts"]
}

0 comments on commit f1e7d70

Please sign in to comment.