npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

typeorm-migrate-to-sql

v1.0.9

Published

general typeorm migrate to sql file

Downloads

55

Readme

typeorm-migrate-to-sql

通过 typeorm 直接生成 sql 语句 , use typeorm to general sql file

Usage

有以下两种用法:

cli

直接通过命令行进行调用

npx typeorm-sql -n migrateName -c typeormConfigPath -d sql general dir

api

直接通过 API 进行调用

(alias) function generalMigrateSql(migrateName: string, typeormConfigPath: string, sqlfiledir: string): Promise<void>

eg:

import { generalMigrateSql } from 'typeorm-migrate-to-sql';
generalMigrateSql(
  'testMigrate',
  './src/config/typeorm.config.ts',
  './migration-sql/',
);

notice

  1. typeormConfig 里面需要注意几个事情,在当前版本(0.2.20)中, export暴露出来的名称必须为 ORMConfig , 即 export = ORMConfig

  2. 如果 typeormConfig 为 ts 语法格式,在调用的时候需要进行转换,可以如下编写 npm script:

    "migrate": "cross-env SERVER_NODE_ENV=development ts-node -r tsconfig-paths/register ./node_modules/typeorm-migrate-to-sql/bin/typeorm-migrate-sql.js -c ./src/config/typeorm.config.ts -d ./migration-sql/"

    "migrate:general": "npm run migrate -- -n"

    调用的时候只需要 npm run migrate:general migrateName

  3. 特别提醒 生成的语句中只包含 typeorm 生成的updown 语句,没有和 migrate 状态有关的信息 sql,比如 migrate 表格信息插入等等