0.1.1 • Published 9 months ago

cca-migrations v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

CCA-Migrations

A powerful PostgreSQL migration tool with support for TypeORM and NestJS. This tool helps you manage database migrations with ease and provides a simple CLI interface.

Features

  • PostgreSQL database support
  • TypeORM integration
  • Migration management (run, revert, fix, force)
  • Support for custom migration files
  • Transaction support
  • Detailed logging

Configuration

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

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

Creating Migrations

  1. Create a migrations directory in your project root:
mkdir migrations
  1. Create a new migration file in the migrations directory. Migration files should follow this format:
module.exports = class YourMigrationName {
  name = 'YourMigrationName'

  async up(queryRunner) {
    // Your migration code here
  }

  async down(queryRunner) {
    // Your rollback code here
  }
}

Usage

Running Migrations

npx cca-migrations run

Reverting Migrations

npx cca-migrations revert

Fixing Migrations

npx cca-migrations fix

Force Running Migrations

npx cca-migrations force

Example Migration

Here's an example migration that creates users and auth tables:

module.exports = class CreateUserAndAuthTables {
  name = 'CreateUserAndAuthTables'

  async up(queryRunner) {
    await queryRunner.query(`
      CREATE TABLE "users" (
        "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
        "email" varchar NOT NULL,
        "name" varchar NOT NULL,
        CONSTRAINT "PK_users" PRIMARY KEY ("id")
      )
    `);
  }

  async down(queryRunner) {
    await queryRunner.query(`DROP TABLE "users"`);
  }
}

Error Handling

The tool provides detailed error messages and logging. If you encounter any issues:

  1. Check your database configuration
  2. Ensure migrations directory exists
  3. Verify migration file syntax
  4. Check database permissions

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

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

Author

Mindaugas Baltrunas mindaugaskul@gmail.com

Support

For support, email mindaugaskul@gmail.com or create an issue at https://github.com/minde8888/cca-migrations/issues

0.0.84

9 months ago

0.0.85

9 months ago

0.0.86

9 months ago

0.0.87

9 months ago

0.0.88

9 months ago

0.0.89

9 months ago

0.0.80

9 months ago

0.0.82

9 months ago

0.0.83

9 months ago

0.0.73

9 months ago

0.0.74

9 months ago

0.0.75

9 months ago

0.0.76

9 months ago

0.0.77

9 months ago

0.0.78

9 months ago

0.0.79

9 months ago

0.0.70

9 months ago

0.0.71

9 months ago

0.0.72

9 months ago

0.1.0

9 months ago

0.1.1

9 months ago

0.0.62

9 months ago

0.0.63

9 months ago

0.0.64

9 months ago

0.0.65

9 months ago

0.0.66

9 months ago

0.0.68

9 months ago

0.0.69

9 months ago

0.0.60

9 months ago

0.0.61

9 months ago

0.0.59

9 months ago

0.0.95

9 months ago

0.0.55

9 months ago

0.0.56

9 months ago

0.0.57

9 months ago

0.0.58

9 months ago

0.0.90

9 months ago

0.0.91

9 months ago

0.0.92

9 months ago

0.0.93

9 months ago

0.0.94

9 months ago

0.0.40

9 months ago

0.0.41

9 months ago

0.0.42

9 months ago

0.0.43

9 months ago

0.0.44

9 months ago

0.0.45

9 months ago

0.0.46

9 months ago

0.0.47

9 months ago

0.0.37

9 months ago

0.0.38

9 months ago

0.0.39

9 months ago

0.0.30

9 months ago

0.0.31

9 months ago

0.0.32

9 months ago

0.0.33

9 months ago

0.0.34

9 months ago

0.0.35

9 months ago

0.0.36

9 months ago

0.0.26

10 months ago

0.0.27

9 months ago

0.0.28

9 months ago

0.0.29

9 months ago

0.0.25

10 months ago

0.0.51

9 months ago

0.0.52

9 months ago

0.0.53

9 months ago

0.0.54

9 months ago

0.0.50

9 months ago

0.0.48

9 months ago

0.0.49

9 months ago

0.0.24

10 months ago

0.0.23

10 months ago

0.0.22

10 months ago

0.0.21

10 months ago

0.0.20

10 months ago

0.0.19

10 months ago

0.0.18

10 months ago

0.0.17

10 months ago

0.0.16

10 months ago

0.0.15

10 months ago

0.0.14

10 months ago

0.0.13

10 months ago

0.0.12

10 months ago

0.0.11

10 months ago

0.0.10

10 months ago

0.0.9

10 months ago

0.0.8

10 months ago

0.0.6

10 months ago

0.0.5

10 months ago

0.0.4

10 months ago

0.0.3

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago