diff --git a/README.md b/README.md index 5f3a755..70a6a59 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,15 @@ Consider all environment variables required. - Formatting: `pnpm format` - Linting (if you don't have an ESLint plugin): `pnpm format` +## Creating migrations + +Creating migrations is a little awkward because TypeORM expects `ts-node`, which uses `tsc`. +To create a migration, first run `pnpm build`, +then run `pnpm typeorm migration:generate -p -d ./dist/db/index.js ./src/db/migrations/`, +replacing `` with the name of the migration you're creating. +Then rename the created file to end in `.js` and remove the TypeScript-specific code from it. +(Yes, this is incredibly janky, but it works, and it only needs to be done once per migration, actually migrating works flawlessly) + ## License Mercury is licensed under the GNU Affero General Public License, version 3 **only**. diff --git a/package.json b/package.json index 9698dbb..0c941ea 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,8 @@ "watch:dev": "nodemon --watch \"dist/**/*\" -e js ./dist/index.js", "format": "prettier -w", "lint": "eslint src/", - "typeorm": "typeorm-ts-node-esm", - "migrate": "typeorm-ts-node-esm migration:run -d ./src/db/index.ts" + "typeorm": "typeorm", + "migrate": "pnpm build && typeorm migration:run -d ./dist/db/index.js" }, "dependencies": { "argon2": "^0.30.3", diff --git a/tsconfig.json b/tsconfig.json index 315db74..01f9e71 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,5 +21,6 @@ "~/*": ["./src/*"], "~entities/*": ["./src/db/entities/*"] } - } + }, + "exclude": ["./dist/"] }