Skip to content

Commit

Permalink
Merge pull request #34 from ScopeSV/migrate-db
Browse files Browse the repository at this point in the history
Migrate db
  • Loading branch information
ScopeSV authored Nov 23, 2023
2 parents 3f57670 + 3239b60 commit fe01d87
Show file tree
Hide file tree
Showing 9 changed files with 637 additions and 1 deletion.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ in the root of your project, add a config file `.kyselinecfg.json`
{
"migrationDir": path, // add path to your migrations directory
"useJsExtension": bool // optional
// if you want to handle migrations and rollbacks for dev base through this cli
"dbCreds": {
"host": string
"port": number
"user": string
"password": string
"database": string
"ssl": boolean
}

}
```

Expand All @@ -42,6 +52,26 @@ To remove fields from an existing table:
$ npx kyseline migration:make remove_foo_from_footable foo
```

#### Run migrations and rollbacks

Supported databases:

- PostgreSQL

To run your migrations, make sure the `.kyselinecfg.json` has the `dbCreds` field filled out.

Migrate up

```bash
$ npx kyseline migrate:up
```

Migrate down one step

```bash
$ npx kyseline migrate:down
```

<!-- ## Deployment
Add additional notes about how to deploy this on a live system -->
Expand Down
8 changes: 8 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
db:
image: postgres:15.4-alpine
environment:
- POSTGRES_PASSWORD=user
- POSTGRES_DB=db
ports:
- 8893:5432
Loading

0 comments on commit fe01d87

Please sign in to comment.