migrations

package
v0.0.0-...-7de60c2 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

README

Creating a new migration

  1. Create a new file based on the current date and time (see existing migration format)
  2. Copy the following code and update MY_ID_HERE and MY_COMMENT_HERE and DO_SOMETHING_HERE
  3. Add the ID to the list of migrations in migrate.go
  4. If possible, add a rollback function.

For Postgres/Sqlite specific migrations, see the initial migration

package migrations

import (
  "github.com/go-gormigrate/gormigrate/v2"
  "gorm.io/gorm"
)

// MY_COMMENT_HERE
var _MY_ID_HERE = &gormigrate.Migration {
  ID: "MY_ID_HERE",
  Migrate: func(tx *gorm.DB) error {
    return DO_SOMETHING_HERE.Error;
  },
  Rollback: func(tx *gorm.DB) error {
    return nil;
  },
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(db *gorm.DB) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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