Documentation ¶
Overview ¶
Package migration is used for migration
The table structure is as follow:
CREATE TABLE `migrations` ( `id_migration` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'surrogate key', `name` varchar(255) DEFAULT NULL COMMENT 'migration name, unique', `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'date migrated or rolled back', `statements` longtext COMMENT 'SQL statements for this migration', `rollback_statements` longtext, `status` enum('update','rollback') DEFAULT NULL COMMENT 'update indicates it is a normal migration while rollback means this migration is rolled back', PRIMARY KEY (`id_migration`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Index ¶
- Constants
- func Create(tbname string, columns ...Column) string
- func Drop(tbname string, columns ...Column) string
- func Refresh() error
- func Register(name string, m Migrationer) error
- func Reset() error
- func Rollback(name string) error
- func TableDDL(tbname string, columns ...Column) string
- func Upgrade(lasttime int64) error
- type Column
- type Migration
- type Migrationer
- type Table
Constants ¶
View Source
const ( DateFormat = "20060102_150405" DBDateFormat = "2006-01-02 15:04:05" )
const the data format for the bee generate migration datatype
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register(name string, m Migrationer) error
Register register the Migration in the map
Types ¶
type Migration ¶
type Migration struct { Created string // contains filtered or unexported fields }
Migration the basic type which will implement the basic type
func (*Migration) Down ¶
func (m *Migration) Down()
Down implement in the Inheritance struct for down
func (*Migration) GetCreated ¶
GetCreated get the unixtime from the Created
type Migrationer ¶
type Migrationer interface { Up() Down() Reset() Exec(name, status string) error GetCreated() int64 }
Migrationer is an interface for all Migration struct
Click to show internal directories.
Click to hide internal directories.