GithubHelp home page GithubHelp logo

knu / git-merge-structure-sql Goto Github PK

View Code? Open in Web Editor NEW
31.0 4.0 2.0 20 KB

git merge driver for db/structure.sql of Rails projects

License: BSD 2-Clause "Simplified" License

Ruby 98.83% Shell 1.17%

git-merge-structure-sql's Introduction

git-merge-structure-sql

This is a merge driver for Git that resolves typical merge conflicts in a db/structure.sql file of Rails.

When your project is configured with config.active_record.schema_format = :sql, the database schema is kept in db/structure.sql instead of db/schema.rb in the native dump format of the underlying database engine, which is not suitable for the default merge driver of Git to deal with. As a result, when you try to merge two branches you always have to resolve trivial conflicts manually if new schema migrations take place in both branches. This custom driver takes away such a pain.

Currently only PostgreSQL, MySQL and SQLite3 dump formats are supported.

Installation

Run this:

$ gem install git-merge-structure-sql

And enable it yourself in your Git configuration, or let it do that for you by this command:

$ git-merge-structure-sql --install

This adds necessary settings to your ~/.gitconfig or $XDG_CONFIG_HOME/git/config and the default gitattributes(5) file to enable the merge driver for structure.sql files.

If you want to enable this driver only in the current git directory, run this:

$ git-merge-structure-sql --install=local

Usage

Once enabled, Git should call this driver as necessary when it needs to merge changes made in structure.sql.

History

See CHANGELOG.md for the version history.

Author

Copyright (c) 2018-2021 Akinori MUSHA.

Licensed under the 2-clause BSD license. See LICENSE.txt for details.

Visit the GitHub Repository for the latest information.

git-merge-structure-sql's People

Contributors

knu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

git-merge-structure-sql's Issues

git-merge-structure-sql: No such file or directory @ rb_sysopen - /Users/X/.gitattributes

Thanks for the work on this, looks great!

When I was running git-merge-structure-sql --install, I got the error:

git-merge-structure-sql: No such file or directory @ rb_sysopen - /Users/X/.gitattributes

I'm not entirely sure how .gitattributes normally gets initialized, but I was wondering how you generally approach this. We want to have this initialized easily for our engineering team, so not doing this manually would be ideal. Additionally, we are running this directly from a rails codebase and have a .gitattributes file checked in, but based on the locations searches, it won't use it. So, we see 2 options:

  1. Find a way to initialize .gitattributes, not sure if it makes sense to be in this library
  2. Support looking for .gitattributes in the current directory we are installing git-merge-structure-sql in

Maybe we are approaching this wrong and there's another approach that would work, suggestions welcome!

/cc @alexanderjeurissen

Feature Request: respect .gitattributes

I typically recommend teams to use .gitattributes for recommended tooling that most team members are encouraged to use. ie the structure merge-driver; rails credentials for filter/smudge; etc

For repositories that already have the merge-structure-sql driver configured in .gitattributes, it is redundant (and potentially confusing to debug) when the local installation still writes to .git/info/attributes.

It would be nice if git-merge-structure-sql --install=local would detect that merge-structure-sql is already registered in .gitattributes (perhaps even checking db/.gitattributes? does git provide a plumbing command for checking this?) and to skip writing .git/info/attributes.

Thanks for the merge-driver; Works great!

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.