Skip to content

Commit

Permalink
Merge pull request #9 from Alviner/feature/refact
Browse files Browse the repository at this point in the history
Feature/refact
  • Loading branch information
Alviner authored Jan 25, 2024
2 parents 6f2b68e + 2abc952 commit b4c0fb1
Show file tree
Hide file tree
Showing 16 changed files with 363 additions and 330 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ jobs:
- name: Test
run: make test
env:
TEST_PG_DNS: postgres://pguser:pgpass@localhost:5432/pgdb
TEST_PG_DNS: postgresql://pguser:pgpass@localhost:5432/pgdb
68 changes: 4 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,8 @@ go get github.com/Alviner/drillerfy
Provides functionality to easily create and drop databases.
This is particularly useful in testing environments where you need to set up a fresh database instance for each test run and clean it up afterward.

```(go)
package main
import (
"context"
"database/sql"
"log"
"github.com/Alviner/drillerfy/database"
_ "github.com/jackc/pgx/v5/stdlib"
)
func main() {
conn, err := sql.Open("pgx", "database dns")
if err != nil {
log.Fatal(err)
}
database, err := database.New(database.WithDialect(database.DialectPostgres))
if err != nil {
log.Fatal(err)
}
dbName, closer, err := database.Create(context.Background(), "test", conn)
if err != nil {
log.Fatal(err)
}
defer closer()
// ... some useful staff with created db
}
```go:examples/tempdb/main.py

```

### Migrations Module
Expand All @@ -66,40 +39,8 @@ Provides functionality to easily run stairway tests for migrations via goose Pro
This module simplifies the process of applying and reverting database schema changes,
which is essential in maintaining consistent database states for testing.

```(go)
package main
import (
"database/sql"
"log"
"os"
"time"
_ "github.com/jackc/pgx/v5/stdlib"
"github.com/Alviner/drillerfy/migrations"
"github.com/pressly/goose/v3"
)
func main() {
db, err := sql.Open("pgx", "database dns")
if err != nil {
log.Fatal(err)
}
provider, err := goose.NewProvider(
goose.DialectPostgres,
db,
os.DirFS("migrations"),
)
if err != nil {
log.Fatal(err)
}
migrator := migrations.New(provider)
if err := migrator.Stairway(2 * time.Second); err != nil {
log.Fatal(err)
}
}
```go:examples/migoose/main.py

```

## Contributing
Expand All @@ -117,4 +58,3 @@ See the LICENSE file in the repository for full license text.

Drillerfy was created and is maintained by [Alviner](https://github.com/Alviner).
Contributions from the community are appreciated.
````
101 changes: 0 additions & 101 deletions database/database.go

This file was deleted.

126 changes: 0 additions & 126 deletions database/database_postgres_test.go

This file was deleted.

27 changes: 0 additions & 27 deletions database/querier/postgres.go

This file was deleted.

9 changes: 0 additions & 9 deletions database/querier/querier.go

This file was deleted.

33 changes: 33 additions & 0 deletions examples/migoose/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package main

import (
"database/sql"
"log"
"os"
"time"

_ "github.com/jackc/pgx/v5/stdlib"

"github.com/Alviner/drillerfy/migoose"
"github.com/pressly/goose/v3"
)

func main() {
db, err := sql.Open("pgx", "database dns")
if err != nil {
log.Fatal(err)
}
provider, err := goose.NewProvider(
goose.DialectPostgres,
db,
os.DirFS("migrations"),
)
if err != nil {
log.Fatal(err)
}
migrator := migoose.New(provider)

if err := migrator.Stairway(2 * time.Second); err != nil {
log.Fatal(err)
}
}
Loading

0 comments on commit b4c0fb1

Please sign in to comment.