migration

package
v0.0.0-...-b553abb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2019 License: Apache-2.0 Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package migration provides tools for database schema migrations.

TODO(CyS): https://povilasv.me/2017/02/20/go-schema-migration-tools/

TL;DR If your looking for schema migration tool you can use:

mattes/migrate, SQL defined schema migrations, with a well defined and documented API, large database support and a useful CLI tool. This tool is actively maintained, has a lot of stars and an A+ from goreport.

rubenv/sql-migrate, go struct based or SQL defined schema migrations, with a config file, migration history, prod-dev-test environments. The only drawback is that it got B from goreport. SQL Schema migration tool for Go. Based on gorp and goose. Is better because the API for using it within your code (FOSDEM2016).

https://bitbucket.org/liamstask/goose goose is a database migration tool. You can manage your database's evolution by creating incremental SQL or Go scripts. Cons: https://www.reddit.com/r/golang/comments/2dlbz5/database_migration_handling_in_go/

github.com/mattes/migrate 744 Stars A migration helper written in Go. Use it in your existing Golang code or run commands via the CLI.

https://github.com/golang-migrate/migrate

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToUTF8MB4

func ToUTF8MB4(ctx context.Context, db interface {
	dml.Querier
	dml.Execer
	dml.Preparer
}) error

ToUTF8MB4 converts MySQL compatible databases from utf8 to utf8mb4. What’s the difference between utf8 and utf8mb4? MySQL decided that UTF-8 can only hold 3 bytes per character. Why? No good reason can be found documented anywhere. Few years later, when MySQL 5.5.3 was released, they introduced a new encoding called utf8mb4, which is actually the real 4-byte utf8 encoding that you know and love.

# Run this once on each schema you have (Replace database_name with your schema name) ALTER DATABASE database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;

# Run this once for each table you have (replace table_name with the table name) ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

# Run this for each column (replace table name, column_name, the column type, maximum length, etc.) ALTER TABLE table_name CHANGE column_name column_name VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL