Name: pq2gorm
Owner: Wantedly, Inc.
Description: Generate gorm model structs from PostgreSQL database schema
Created: 2016-08-29 10:47:02.0
Updated: 2018-05-05 08:23:14.0
Pushed: 2016-09-27 05:46:57.0
Homepage: null
Size: 73
Language: Go
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
pq2gorm is a generator of gorm model structs from a PostgresSQL database.
Prepare Go 1.6 or higher.
Go 1.5 is acceptable, but GO15VENDOREXPERIMENT=1
must be set.
After installing required version of Go, you can build and install pq2gorm
by
get -d -u github.com/wantedly/pq2gorm
$GOPATH/src/github.com/wantedly/pq2gorm
ke
ke install
make
generates a binary into bin/pq2gorm
.
make install
put it to $GOPATH/bin
.
Run pq2gorm
with Connection URI of a PostgresSQL database.
Connection URI is necessary for running.
2gorm
e: Generate gorm model structs from PostgreSQL database schema.
string
Set output path (default "./")
ir string
Set output path (default "./")
string
Target tables (table1,table2,...) (default: all tables)
ables string
Target tables (table1,table2,...) (default: all tables)
Example 1: Generate gorm model files of all tables in current directory.
2gorm "postgresql://user:password@host:port/dbname?sslmode=disable"
For example, user model user.go as shown below will be generated:
User struct {
ID uint `json:"id"`
...
Example 2: Generate gorm model files of all tables in ./out
directory.
2gorm "postgresql://user:password@host:port/dbname?sslmode=disable" -d ./out
Example 3: Generate gorm model files of profiles
and users
tables.
2gorm "postgresql://user:password@host:port/dbname?sslmode=disable" -d ./out -t profiles,users
If the directory ./out
does not exist, pq2gorm
creates ./out
directory with output files.