0.1.1 • Published 7 months ago

cca-migrations v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 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

7 months ago

0.0.85

7 months ago

0.0.86

7 months ago

0.0.87

7 months ago

0.0.88

7 months ago

0.0.89

7 months ago

0.0.80

7 months ago

0.0.82

7 months ago

0.0.83

7 months ago

0.0.73

7 months ago

0.0.74

7 months ago

0.0.75

7 months ago

0.0.76

7 months ago

0.0.77

7 months ago

0.0.78

7 months ago

0.0.79

7 months ago

0.0.70

7 months ago

0.0.71

7 months ago

0.0.72

7 months ago

0.1.0

7 months ago

0.1.1

7 months ago

0.0.62

7 months ago

0.0.63

7 months ago

0.0.64

7 months ago

0.0.65

7 months ago

0.0.66

7 months ago

0.0.68

7 months ago

0.0.69

7 months ago

0.0.60

7 months ago

0.0.61

7 months ago

0.0.59

7 months ago

0.0.95

7 months ago

0.0.55

7 months ago

0.0.56

7 months ago

0.0.57

7 months ago

0.0.58

7 months ago

0.0.90

7 months ago

0.0.91

7 months ago

0.0.92

7 months ago

0.0.93

7 months ago

0.0.94

7 months ago

0.0.40

7 months ago

0.0.41

7 months ago

0.0.42

7 months ago

0.0.43

7 months ago

0.0.44

7 months ago

0.0.45

7 months ago

0.0.46

7 months ago

0.0.47

7 months ago

0.0.37

7 months ago

0.0.38

7 months ago

0.0.39

7 months ago

0.0.30

7 months ago

0.0.31

7 months ago

0.0.32

7 months ago

0.0.33

7 months ago

0.0.34

7 months ago

0.0.35

7 months ago

0.0.36

7 months ago

0.0.26

7 months ago

0.0.27

7 months ago

0.0.28

7 months ago

0.0.29

7 months ago

0.0.25

7 months ago

0.0.51

7 months ago

0.0.52

7 months ago

0.0.53

7 months ago

0.0.54

7 months ago

0.0.50

7 months ago

0.0.48

7 months ago

0.0.49

7 months ago

0.0.24

7 months ago

0.0.23

7 months ago

0.0.22

7 months ago

0.0.21

7 months ago

0.0.20

7 months ago

0.0.19

7 months ago

0.0.18

7 months ago

0.0.17

7 months ago

0.0.16

7 months ago

0.0.15

7 months ago

0.0.14

7 months ago

0.0.13

7 months ago

0.0.12

7 months ago

0.0.11

7 months ago

0.0.10

7 months ago

0.0.9

7 months ago

0.0.8

7 months ago

0.0.6

7 months ago

0.0.5

7 months ago

0.0.4

7 months ago

0.0.3

7 months ago

0.0.2

7 months ago

0.0.1

7 months ago