Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/refact #9

Merged
merged 4 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading