0.1.1 • Published 8 months ago

cca-migrations v0.1.1

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

8 months ago

0.0.85

8 months ago

0.0.86

8 months ago

0.0.87

8 months ago

0.0.88

8 months ago

0.0.89

8 months ago

0.0.80

8 months ago

0.0.82

8 months ago

0.0.83

8 months ago

0.0.73

8 months ago

0.0.74

8 months ago

0.0.75

8 months ago

0.0.76

8 months ago

0.0.77

8 months ago

0.0.78

8 months ago

0.0.79

8 months ago

0.0.70

8 months ago

0.0.71

8 months ago

0.0.72

8 months ago

0.1.0

8 months ago

0.1.1

8 months ago

0.0.62

8 months ago

0.0.63

8 months ago

0.0.64

8 months ago

0.0.65

8 months ago

0.0.66

8 months ago

0.0.68

8 months ago

0.0.69

8 months ago

0.0.60

8 months ago

0.0.61

8 months ago

0.0.59

8 months ago

0.0.95

8 months ago

0.0.55

8 months ago

0.0.56

8 months ago

0.0.57

8 months ago

0.0.58

8 months ago

0.0.90

8 months ago

0.0.91

8 months ago

0.0.92

8 months ago

0.0.93

8 months ago

0.0.94

8 months ago

0.0.40

8 months ago

0.0.41

8 months ago

0.0.42

8 months ago

0.0.43

8 months ago

0.0.44

8 months ago

0.0.45

8 months ago

0.0.46

8 months ago

0.0.47

8 months ago

0.0.37

8 months ago

0.0.38

8 months ago

0.0.39

8 months ago

0.0.30

8 months ago

0.0.31

8 months ago

0.0.32

8 months ago

0.0.33

8 months ago

0.0.34

8 months ago

0.0.35

8 months ago

0.0.36

8 months ago

0.0.26

8 months ago

0.0.27

8 months ago

0.0.28

8 months ago

0.0.29

8 months ago

0.0.25

8 months ago

0.0.51

8 months ago

0.0.52

8 months ago

0.0.53

8 months ago

0.0.54

8 months ago

0.0.50

8 months ago

0.0.48

8 months ago

0.0.49

8 months ago

0.0.24

8 months ago

0.0.23

8 months ago

0.0.22

8 months ago

0.0.21

8 months ago

0.0.20

8 months ago

0.0.19

8 months ago

0.0.18

8 months ago

0.0.17

8 months ago

0.0.16

8 months ago

0.0.15

8 months ago

0.0.14

8 months ago

0.0.13

8 months ago

0.0.12

8 months ago

0.0.11

8 months ago

0.0.10

8 months ago

0.0.9

8 months ago

0.0.8

8 months ago

0.0.6

8 months ago

0.0.5

8 months ago

0.0.4

8 months ago

0.0.3

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago