Files
netris-nestri/infra/database.ts
Wanjohi 178c612f0f 🐜 fix: Make sure the db uses the same name (#199)
## Description
This fixes the issue where Cloudflare fails

## Related Issues
<!-- List any related issues (e.g., "Closes #123", "Fixes #456") -->

## Type of Change

- [x] Bug fix (non-breaking change)
- [ ] New feature (non-breaking change)
- [ ] Breaking change (fix or feature that changes existing
functionality)
- [ ] Documentation update
- [ ] Other (please describe):

## Checklist

- [x] I have updated relevant documentation
- [x] My code follows the project's coding style
- [x] My changes generate no new warnings/errors
2025-03-02 00:01:25 +03:00

39 lines
944 B
TypeScript

const dbProject = new neon.Project("Nestri", {
historyRetentionSeconds: 86400,
name:"Nestri"
})
const dbBranchId = $app.stage !== "production" ?
new neon.Branch("DatabaseBranch", {
parentId: dbProject.defaultBranchId,
projectId: dbProject.id,
name: $app.stage,
}).id : dbProject.defaultBranchId
const dbEndpoint = new neon.Endpoint("NestriEndpoint", {
projectId: dbProject.id,
branchId: dbBranchId
})
const dbRole = new neon.Role("AdminRole", {
name: "admin",
branchId: dbBranchId,
projectId: dbProject.id,
})
const db = new neon.Database("NestriDatabase", {
branchId: dbBranchId,
projectId: dbProject.id,
ownerName: dbRole.name,
name: `nestri-${$app.stage}`,
})
export const database = new sst.Linkable("Database", {
properties: {
name: db.name,
user: dbRole.name,
host: dbEndpoint.host,
password: dbRole.password,
},
});