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 🙏

© 2025 – Pkg Stats / Ryan Hefner

cca-migration-generator

v0.1.1

Published

PostgreSQL TypeORM migration generator and schema builder with advanced TypeScript support

Downloads

5,582

Readme

CCA Migration Generator

A robust TypeORM migration and table schema generator for PostgreSQL with TypeScript support.

Overview

cca-migration-generator is a CLI tool that streamlines the creation of TypeORM migrations and table schemas for PostgreSQL databases. It offers seamless TypeScript integration and automated migration file generation.

Prerequisites

  • Node.js >= 14
  • PostgreSQL >= 12
  • TypeORM >= 0.3.0
  • TypeScript >= 4.5

Usage

Basic Commands

Generate a new migration:

npx cca-migration-generator CreateUserTable

Getting Started

1. Database Configuration

Create a cca.config.json file in your project root:

{
  "type": "postgres",
  "host": "localhost",
  "port": 5432,
  "username": "username",
  "password": "your_password",
  "database": "your_database"
}

2. Environment Setup

Create a .env file with your database configuration:

DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=your_username
DB_PASSWORD=your_password
DB_NAME=your_database
NODE_ENV=development

3. Project Structure

Recommended project structure:

your-project/
├── src/
|   ├── infrastructure/
|   │   ├── database/
|   │   │   ├── migrations/
|   │   │   │   └── [migration files]
|   │   │   └── config.ts
|   │   └── entities/
|   │       └── [entity files]
├── cca.config.json
└── .env

4. DataSource Configuration

Create a config.ts file for TypeORM configuration:

// src/database/config.ts
export const dataSourceConfig = {
  type: 'postgres',
  host: process.env.DB_HOST,
  port: parseInt(process.env.DB_PORT || '5432'),
  username: process.env.DB_USERNAME,
  password: process.env.DB_PASSWORD,
  database: process.env.DB_NAME,
  entities: [
    // List your entity classes here
  ],
  migrations: [
    // Path to your migrations folder
  ],
  synchronize: false, // Enable only in development
  logging: true,
};

Features

  • Automated TypeORM migration file generation
  • PostgreSQL schema management
  • TypeScript support with type definitions
  • Flexible configuration options
  • Custom migration templates
  • Support for complex database relationships
  • Automatic timestamp handling

Error Handling

Common Issues and Solutions

Configuration Errors

  • Config file not found: Ensure cca.config.json exists in your project root
  • Invalid configuration: Verify database credentials in cca.config.json or .env
  • Connection failed: Check PostgreSQL server status and accessibility

Migration Errors

  • Duplicate migration: Each migration name must be unique
  • Invalid migration path: Verify migration directory configuration
  • Syntax error: Ensure TypeScript syntax is correct in migration files

Best Practices

Migration Management

  • Keep migrations atomic and focused
  • Use meaningful, descriptive migration names
  • Test migrations in development before deploying to production
  • Never modify existing migrations
  • Use transactions for complex migrations

Configuration

  • Store sensitive data in environment variables
  • Maintain separate configurations for development and production
  • Document configuration changes

Type Safety

  • Define TypeScript interfaces for entities
  • Use appropriate column types
  • Implement enums for predefined values

Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to your branch
  5. Create a Pull Request

Support

License

This project is licensed under the MIT License - see the LICENSE file for details.