migrate

package
v0.0.0-...-78f8226 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2016 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunMigrations

func RunMigrations(db *gorm.DB)

RunMigrations runs all migrations

Types

type Migration

type Migration struct {
	Name     string
	Function MigrationFunctionType
}

Migration model

type MigrationFunctionType

type MigrationFunctionType func(db *gorm.DB) error

MigrationFunctionType is func that is called to run the migration for a table

type Sample

type Sample struct {
	// Model
	ID        uint `gorm:"primary_key"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt mysql.NullTime
}

Sample table structure

type SchemaMigration

type SchemaMigration struct {
	MigrationName string    `sql:"unique_index"`
	CreatedAt     time.Time `sql:"DEFAULT:current_timestamp"`
}

SchemaMigration used to see which migrations have run by storing those that have run

Jump to

Keyboard shortcuts

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