A minimalistic PostgreSQL migrations tool inspired by the Rails migration process. Easily generate, apply, or revert database migrations using Node.js.
- Generate migration files with unique timestamps
- Easily apply or revert migrations
- Clean and simple CLI interface
```bash git clone https://github.com/your-github-username/simple-postgres-migrations.git cd simple-postgres-migrations npm install ```
To generate migration files:
```bash node migrate.js generate ```
This will generate two files: one for applying the migration and another for reverting it.
To apply all pending migrations:
```bash node migrate.js up ```
To revert the last applied migration:
```bash node migrate.js down ```
For first-time setup:
```bash node migrate.js setup ```
You must provide a .db.test, .db.development, or .db.production to specify the database config for a given environment in migrate.utils.js with your PostgreSQL connection details:
```javascript export const DB_CONFIG = { host: 'localhost', port: 5432, user: 'your-username', password: 'your-password', database: 'your-database-name' }; ```
Ensure the MIGRATIONS_DIR in migrate.utils.js points to your desired migrations directory:
```javascript export const MIGRATIONS_DIR = path.join(__dirname, 'migrations'); ```
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
