Top 4.7% dependent repos on proxy.golang.org
proxy.golang.org : github.com/baijum/pgmigration
Package pgmigration provides support for PostgreSQL database migrations. This package provide support for migrations written in plain SQL scripts. In your project, place your migrations in a separate folder, for example, "db/migrations". Migrations are sorted using their file name and then applied in the sorted order. Since sorting is important, name your migrations accordingly. For example, add a timestamp before migration name. Or use any other ordering scheme you'll like. Note that migration file names are saved into a table, and the table is used later on to detect which migrations have already been applied. In other words, don't rename your migration files once they've been applied to your DB. Install go-bindata ( https://github.com/jteeuwen/go-bindata ) and run this command: The "bindata.go" file will contain your migrations. Regenerate your "bindata.go" file whenever you add migrations. In your app code, import pgmigration package: Then, run the migrations. **Make sure the migrations have an .sql ending.** Any script with file name prefix as `ignore` will be ignored. After app startup and after a "sql.DB" instance is initialized in your app, run the migrations. Assuming you have a variable called "db" that points to "sql.DB" and the migrations are located in "db/migrations", execute the following code: The last argument is a string pointer which can refer to the last script, if there is any. This will be useful to write tests.
Registry
-
Source
- Documentation
- JSON
purl: pkg:golang/github.com/baijum/pgmigration
License: MIT
Latest release: over 7 years ago
First release: over 7 years ago
Namespace: github.com/baijum
Dependent packages: 1
Dependent repositories: 1
Stars: 1 on GitHub
Forks: 0 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: about 1 month ago