Giter Club home page Giter Club logo

Comments (3)

rnubel avatar rnubel commented on September 15, 2024

@SharkFourSix if your concern is just having an easier way to run pgmgr after adding it to your go.mod, you can run the version pinned by a particular module with go run github.com/rnubel/pgmgr. That is, suppose you make a new Go project and install a specific version of pgmgr:

$ go mod init github.com/rnubel/mynewproject
$ go get github.com/rnubel/[email protected]
$ echo {} > .pgmgr.json

You can run the installed version with the go run command:

$ go run github.com/rnubel/pgmgr -v
pgmgr version 1.1.4

So, e.g., go run github.com/rnubel/pgmgr db create, go run github.com/rnubel/pgmgr db migrate, should all work and use the exact version you have pinned.

I also will add that it is possible to import the pgmgr package and use it directly, but you have to build your config struct by hand:

package main

import (
	"fmt"
	"log"

	"github.com/rnubel/pgmgr/pgmgr"
)

func main() {
	config := pgmgr.Config{
		Host:            "localhost",
		Port:            5432,
		Username:        "rnubel",
		Database:        "mydb",
		MigrationDriver: "psql",
		MigrationFolder: "migrations",
		MigrationTable:  "schema_migrations",
		SslMode:         "disable",
	}

	if err := pgmgr.Create(&config); err != nil {
		log.Fatal(fmt.Errorf("failed to create db: %w", err))
	}

	if err := pgmgr.Migrate(&config); err != nil {
		log.Fatal(fmt.Errorf("failed to migrate: %w", err))
	}
}

Let me know if the above addresses your problem or if there's more you're looking for!

from pgmgr.

SharkFourSix avatar SharkFourSix commented on September 15, 2024

Thanks. I just ended up whipping up my own library that works for me out of frustration 😆

https://github.com/SharkFourSix/dsync

from pgmgr.

rnubel avatar rnubel commented on September 15, 2024

@SharkFourSix good luck with that! I'll close this issue for now.

from pgmgr.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.