Pop v4.7.0 Released!

--

Better logging, Go modules, UNIX timestamps and more. Discover the new Pop release!

In addition to what is listed here, I recommend you read the CHANGELOG for a complete list of what has changed in v4.7.0.

How to Upgrade

Standalone

First, if you use soda without the Buffalo integration, you can upgrade the binary from source, using go get:

$ go get -u -v github.com/gobuffalo/pop/soda

You can also download a pre-built binary at:
https://github.com/gobuffalo/pop/releases/tag/v4.7.0

Buffalo version

If you use the Buffalo integration, you’ll have to upgrade the buffalo binary to use this version:

$ go get -u -v github.com/gobuffalo/buffalo/buffalo

For both versions, if you are using dep, and you pinned Pop to a specific version, you should change the version in Gopkg.toml to v4.7.0. Then run dep ensure -update to update your dependencies.

Otherwise, just run dep ensure -update to update your dependencies.

Go Modules (beta)

You can use Pop with Go modules:

go.mod:

module github.com/gobuffalo/pop-testrequire (
github.com/gobuffalo/pop v4.7.0
)

What’s New

Better logging

Pop logging was a bit difficult to handle before this version: everything was considered as debug traces, some traces were not configurable at all, …

In v4.7.0, the Pop logger was refactored to solve these problems! The old logger signature still works, but you’re encouraged to migrate to the new one. If you use Buffalo and you didn’t customize the default logger, you can wait for Buffalo v0.13.0: we will migrate to the new logger in this version.

The legacy logger signature was:

func(s string, args …interface{})

The new one is:

func(lvl logging.Level, s string, args …interface{})

Available logging levels are (from the less verbose to the most verbose):

  • Warn
  • Info
  • Debug
  • SQL

Go modules

Pop v4.7.0 is the first minor release to introduce beta Go modules support. We’re still working on it, but it should work now.

If you prefer to stay on the v4.6.0 series, you can pick the v4.6.9 release which also support Go modules and introduces some backported bug fixes.

UNIX timestamps

If you define the CreatedAt and UpdatedAt fields in your model struct (and they are created by default when you use the model generator), Pop will manage them for you. It means when you create a new entity in the database, the CreatedAt field will be set to the current datetime, and UpdatedAt will be set each time you update an existing entity.

These fields are defined as time.Time, but now you can define them as int and handle them as UNIX timestamps.

type User struct {
ID int `db:"id"`
CreatedAt int `db:"created_at"`
UpdatedAt int `db:"updated_at"`
FirstName string `db:"first_name"`
LastName string `db:"last_name"`
}

If you use fizz migrations, make sure to define these fields by yourself, and disable the default datetime timestamps:

create_table(“users”) {
t.Column("id", "int", {primary: true})
t.Column(“created_at”, “int”)
t.Column(“updated_at”, “int”)
t.Column(“first_name”, “string”)
t.Column(“last_name”, “string”)
t.DisableTimestamps()
}

I hope you’ll enjoy this new version! Feel free to open an issue if you find a bug, or ask for support on the buffalo Slack channel.

--

--