migratorCli

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2024 License: MIT Imports: 5 Imported by: 0

README

bun-migrator-cli

Golang's Bun ORM migration cli initializer.

This is the small wrapper to the Bun migration package. This package includes migration cli configuration with basic migration functionality.

You can read more about the Migration Tool in Bun Migration Docs.

Also, Most of the code used here is taken from Bun Example Project

Install
go get github.com/iambpn/bun-migrator-cli

Usage

package main

import (
  "database/sql"
  "log"
  "os"

  "github.com/uptrace/bun"
  "github.com/uptrace/bun/dialect/sqlitedialect"
  "github.com/uptrace/bun/driver/sqliteshim"
  "github.com/uptrace/bun/migrate"
  migratorCli "github.com/iambpn/bun-migrator-cli"
)

// instantiate DB
sqlDb, err := sql.Open(sqliteshim.ShimName, "file::memory:?cache=shared")

if err != nil {
  log.Fatal(err)
}

// get bun db instance
db := bun.NewDB(sqlDb, sqlitedialect.New())

// instantiate Migrator
migrator := migrate.NewMigrator(db, Migrations)

// initialize cli
migratorCli.InitCli(migrator, os.Args)

Resources:

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitCli

func InitCli(migrator *migrate.Migrator, osArgs []string, extendCli ...*cli.Command)

InitCli initializes the cli with the given migrator and os args extendCli can be used to add additional commands to the cli

Types

This section is empty.

Jump to

Keyboard shortcuts

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