https://github.com/stolen-ruby/conflict_free_schema
Conflict free-schema solution for your Rails app that is running on top of Postgresql
https://github.com/stolen-ruby/conflict_free_schema
postgresql rails schema-migrations
Last synced: 6 months ago
JSON representation
Conflict free-schema solution for your Rails app that is running on top of Postgresql
- Host: GitHub
- URL: https://github.com/stolen-ruby/conflict_free_schema
- Owner: stolen-ruby
- License: mit
- Created: 2021-03-18T19:14:32.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-11-12T06:06:38.000Z (about 1 year ago)
- Last Synced: 2025-06-29T07:42:33.976Z (7 months ago)
- Topics: postgresql, rails, schema-migrations
- Language: Ruby
- Homepage:
- Size: 41 KB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README

### Why stolen ruby?
_Stolen ruby_ is an idea behind extracting open-source code into more accessible packages. I noticed that a lot of interesting projects have quite a lot of brilliant code that is unfortunately often _embedded_ into the source and never extracted - which is a shame because often it's very useful stuff and a lot of different people could benefit from it. The idea is to change that - extract those hidden gems and publish them into the world.
_Note: cover stolen [from well known book](https://austinkleon.com/steal/)._
# conflict_free_schema

**Stolen from:** [GitLab](https://gitlab.com); references: [merge request](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/30109#65c74abf34b80b85fc4b56a98b029c7e2d884bac), [issue](https://gitlab.com/gitlab-org/gitlab/-/issues/218590)
Original author: Patrick Bair; extracted code with very minor modifications, added higher-level Rails integrations tests on top
## Requirements
Rails 6+ with postgresql
## Installation
Add the following to your `Gemfile`:
~~~ruby
gem 'conflict_free_schema'
~~~
Then install the gem using bundle:
~~~bash
bundle install
~~~
Gem will auto-hook into your rails app via `Rails::Railtie`
## What does it do?
> Remove conflicts from structure.sql that are caused by tracking the schema_migrations.versions information. To do this, store an empty file named after each version under the db/schema_migrations directory. That way when we versions are added or removed, we add or delete files from the directory, which should not conflict with other changes.
If you're using `structure.sql` in your Rails project with postgresql - instead of putting schema version in the sql file upon dump, each migration will be stored as a separate file in `db/schema_migrations` (with a SHA hash as content so it's a unique file from git's perspective). If you're doing a lot of structure changes across your organization it should make the life of your developers much easier - resolving conflicts in structure is pain already - even without the need to resolve schema migrations version numbers.
## Development
You can spin up docker-based development environment with provided `docker-compose` file (useful for Apple M1 users) or simply install dependencies locally.