SvelteKit Project 생성
npm create svelte@latest test1
# Skeleton project
# using TypeScript
# check ESLint, Prettier, Playwright, Vitest
cd test1
bun i
TypeORM 설정
참조: https://typeorm.io/#installation
bun add typeorm reflect-metadata pg
bun add @types/node tsconfig-paths tsx -d
tsconfig.json
"compilerOptions": {
...
"emitDecoratorMetadata": true,
"experimentalDecorators": true
}
package.json
"scripts": {
...
"typeorm": "tsx -r tsconfig-paths/register ./node_modules/typeorm/cli.js --dataSource src/lib/typeorm/config.ts",
"migration:create": "tsx -r tsconfig-paths/register ./node_modules/typeorm/cli.js migration:create src/lib/typeorm/migrations/Migration",
"migration:generate": "npm run typeorm migration:generate src/lib/typeorm/migrations/Migration",
"migration:run": "npm run typeorm migration:run"
}
src/lib/typeorm/config.ts
import { DataSource } from 'typeorm';
export const AppDataSource = new DataSource({
type: 'postgres',
host: 'localhost',
port: 5432,
username: 'postgres',
password: 'default_password',
database: 'postgres',
synchronize: false,
logging: true,
entities: ['src/lib/typeorm/entity/*.ts'],
subscribers: [],
migrations: ['src/lib/typeorm/migrations/*.ts']
});
테스트
npm run migration:create
Top comments (0)