Giter VIP home page Giter VIP logo

dsync's Introduction

dsync Go Report Card

Getting Started

go get github.com/SharkFourSix/dsync

Usage

  1. Choose a data source (check in sources) or implement your own.
  2. Create a Migrator and pass the data source to the migrator
import (
	"embed"
	"testing"

	"github.com/SharkFourSix/dsync"
	"github.com/SharkFourSix/dsync/sources/postgresql"
)

//go:embed resources/migrations
var efs embed.FS

func DoMigrate(){
    dsn := "postgres://postgres:toor@localhost:5433/test-db"
    
    // Create a migrator
    var migrator dsync.Migrator

    // Configure a data source
	ds, err := postgresql.New(dsn, &dsync.Config{
		FileSystem: efs,
		Basepath:   BASEPATH,
		TableName:  "dsync_schema_migration",
	})

	if err != nil {
        panic(err)
	}

    // Migrate
	err = migrator.Migrate(ds)
	if err != nil {
		panic(err)
		return
	}
}

Things To Know

  • File names must use the following convention to be included when scanning:

    \d+__\w+.sql.

  • An error will be returned otherwise when the version part of the file name does not contain a number.

  • A migration script will not be included if it does not end with .sql extension

  • Migrations are only recorded in the database when successfull

  • Custom migration table name to allow different migrations for difference DB clients.

  • Supports out of order migrations

Database sources

Database Data source Status
Postgres github.com/SharkFourSix/dsync/sources/postgresql Done
MySQL github.com/SharkFourSix/dsync/sources/mysql Done
SQLite github.com/SharkFourSix/dsync/sources/sqlite Done

TODO

  • Add logging and configuration

dsync's People

Contributors

sharkfoursix avatar

Stargazers

Watipaso RattleStack Chirambo avatar Walter Kaunda avatar Zikani Nyirenda Mwase avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.