-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from GenieWizards/feat/add-seed-data
feat(seed-data): reset and add seed data in DB in dev mode✨
- Loading branch information
Showing
3 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* eslint-disable no-console */ | ||
import { reset, seed } from "drizzle-seed"; | ||
|
||
import { db } from "../adapter"; | ||
import * as schema from "../schemas"; | ||
|
||
async function main() { | ||
try { | ||
console.log("Resetting the database"); | ||
await reset(db, schema); | ||
console.log("Seed script execution started...."); | ||
await seed(db, schema).refine(fn => ({ | ||
expenseModel: { | ||
columns: { | ||
currency: fn.default({ | ||
defaultValue: "INR", | ||
}), | ||
}, | ||
}, | ||
})); | ||
console.log("Seed script executed successfully"); | ||
process.exit(0); | ||
} catch (error) { | ||
console.log("Something went wrong in seed script execution", error); | ||
} | ||
} | ||
|
||
await main(); |