version_control

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: MIT Imports: 10 Imported by: 0

README

go-mysql-version-control

This a project to manage sql files.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB
View Source
var FILES_EXECUTED = []SQLVersion{}
View Source
var FILES_IN_PATH = []SQLVersion{}
View Source
var FILES_NOT_EXECUTED = []SQLVersion{}
View Source
var INIT_SQL = "CREATE TABLE `sql_version`  (" +
	"`version` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL," +
	"`name` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL," +
	"`hash` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL," +
	"`create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP," +
	"PRIMARY KEY (`version`) USING BTREE" +
	") ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;"
View Source
var MAX_VERSION = "0.0.0"
View Source
var TABLE_NAME = "sql_version"

Functions

func Hash

func Hash(val string) string

func VersionLastThan

func VersionLastThan(a, b string) bool

Types

type MySQLVersionController

type MySQLVersionController struct {
}

func NewController

func NewController(db *gorm.DB) *MySQLVersionController

func (*MySQLVersionController) CheckSqlFiles

func (c *MySQLVersionController) CheckSqlFiles()

func (*MySQLVersionController) ExecuteSqlFiles

func (c *MySQLVersionController) ExecuteSqlFiles()

func (*MySQLVersionController) QueryAllVersion

func (c *MySQLVersionController) QueryAllVersion()

Query all executed versions

func (*MySQLVersionController) QuerySqlFiles

func (c *MySQLVersionController) QuerySqlFiles(path string) []fs.DirEntry

Check sql files' names are legal file name must has the format x.x.x_name.sql x is number

func (*MySQLVersionController) ReadFilesInDisk

func (c *MySQLVersionController) ReadFilesInDisk(path string)

func (*MySQLVersionController) Start

func (c *MySQLVersionController) Start(path string)

Init table

type SQLVersion

type SQLVersion struct {
	Version    string `gorm:"primaryKey"`
	Name       string
	Hash       string
	CreateTime time.Time
}

Jump to

Keyboard shortcuts

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