├── .github └── workflows │ └── rspec.yml ├── .gitignore ├── .rspec ├── .rubocop_schema.49.yml ├── .rubocop_schema.53.yml ├── .rubocop_schema.77.yml ├── .rubocop_schema.yml ├── Gemfile ├── LICENSE.txt ├── README.md ├── Rakefile ├── fix-db-schema-conflicts.gemspec ├── lib ├── fix-db-schema-conflicts.rb └── fix_db_schema_conflicts │ ├── autocorrect_configuration.rb │ ├── railtie.rb │ ├── schema_dumper.rb │ ├── tasks │ └── db.rake │ └── version.rb └── spec ├── integration └── integration_spec.rb ├── spec_helper.rb ├── test-app ├── .gitignore ├── Gemfile ├── Gemfile.lock ├── README.rdoc ├── Rakefile ├── app │ ├── assets │ │ ├── config │ │ │ └── manifest.js │ │ ├── images │ │ │ └── .keep │ │ ├── javascripts │ │ │ └── application.js │ │ └── stylesheets │ │ │ └── application.css │ ├── controllers │ │ ├── application_controller.rb │ │ └── concerns │ │ │ └── .keep │ ├── helpers │ │ └── application_helper.rb │ ├── mailers │ │ └── .keep │ ├── models │ │ ├── .keep │ │ ├── company.rb │ │ ├── concerns │ │ │ └── .keep │ │ └── person.rb │ └── views │ │ └── layouts │ │ └── application.html.erb ├── bin │ ├── bundle │ ├── rails │ ├── rake │ ├── setup │ └── spring ├── config.ru ├── config │ ├── application.rb │ ├── boot.rb │ ├── database.yml │ ├── environment.rb │ ├── environments │ │ ├── development.rb │ │ ├── production.rb │ │ └── test.rb │ ├── initializers │ │ ├── assets.rb │ │ ├── backtrace_silencers.rb │ │ ├── cookies_serializer.rb │ │ ├── filter_parameter_logging.rb │ │ ├── inflections.rb │ │ ├── mime_types.rb │ │ ├── session_store.rb │ │ └── wrap_parameters.rb │ ├── locales │ │ └── en.yml │ ├── routes.rb │ └── secrets.yml ├── db │ ├── migrate │ │ ├── 20160322223225_create_people.rb │ │ └── 20160322223258_create_companies.rb │ ├── schema.rb │ └── seeds.rb ├── lib │ ├── assets │ │ └── .keep │ └── tasks │ │ └── .keep ├── log │ └── .keep ├── public │ ├── 404.html │ ├── 422.html │ ├── 500.html │ ├── favicon.ico │ └── robots.txt ├── test │ ├── controllers │ │ └── .keep │ ├── fixtures │ │ ├── .keep │ │ ├── companies.yml │ │ └── people.yml │ ├── helpers │ │ └── .keep │ ├── integration │ │ └── .keep │ ├── mailers │ │ └── .keep │ ├── models │ │ ├── .keep │ │ ├── company_test.rb │ │ └── person_test.rb │ └── test_helper.rb └── vendor │ └── assets │ ├── javascripts │ └── .keep │ └── stylesheets │ └── .keep └── unit └── autocorrect_configuration_spec.rb /.github/workflows/rspec.yml: -------------------------------------------------------------------------------- 1 | name: Run rspec 2 | on: 3 | push: 4 | pull_request: 5 | branches: [ master ] 6 | jobs: 7 | build: 8 | runs-on: ubuntu-18.04 9 | strategy: 10 | fail-fast: false 11 | matrix: 12 | ruby: [ 2.4, 2.5, 2.6 ] 13 | name: rspec with ruby ${{ matrix.ruby }} 14 | steps: 15 | - uses: actions/checkout@v2 16 | - uses: ruby/setup-ruby@v1 17 | with: 18 | ruby-version: ${{ matrix.ruby }} 19 | bundler-cache: true 20 | bundler: 1 21 | 22 | - run: bundle exec rspec -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle/ 2 | /.yardoc 3 | /Gemfile.lock 4 | /_yardoc/ 5 | /coverage/ 6 | /doc/ 7 | /pkg/ 8 | /spec/reports/ 9 | /tmp/ 10 | *.bundle 11 | *.so 12 | *.o 13 | *.a 14 | mkmf.log 15 | *.gem 16 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --require spec_helper 3 | -------------------------------------------------------------------------------- /.rubocop_schema.49.yml: -------------------------------------------------------------------------------- 1 | # Configuration for Rubocop >= 0.49.0 2 | 3 | Layout/AlignHash: 4 | EnforcedColonStyle: 'key' 5 | EnforcedHashRocketStyle: 'key' 6 | 7 | Layout/ExtraSpacing: 8 | # When true, allows most uses of extra spacing if the intent is to align 9 | # things with the previous or next line, not counting empty lines or comment 10 | # lines. 11 | AllowForAlignment: false 12 | 13 | Layout/SpaceBeforeFirstArg: 14 | Enabled: true 15 | 16 | Style/NumericLiterals: 17 | Enabled: false 18 | 19 | Metrics/BlockNesting: 20 | Max: 2 21 | 22 | Style/WordArray: 23 | Enabled: false 24 | 25 | Style/TrailingCommaInLiteral: 26 | EnforcedStyleForMultiline: 'comma' 27 | 28 | Style/TrailingCommaInArguments: 29 | EnforcedStyleForMultiline: 'comma' 30 | 31 | Style/HashSyntax: 32 | EnforcedStyle: 'ruby19' 33 | 34 | Style/StringLiterals: 35 | EnforcedStyle: double_quotes 36 | -------------------------------------------------------------------------------- /.rubocop_schema.53.yml: -------------------------------------------------------------------------------- 1 | # Configuration for Rubocop >= 0.53.0 2 | 3 | Layout/AlignHash: 4 | EnforcedColonStyle: 'key' 5 | EnforcedHashRocketStyle: 'key' 6 | 7 | Layout/ExtraSpacing: 8 | # When true, allows most uses of extra spacing if the intent is to align 9 | # things with the previous or next line, not counting empty lines or comment 10 | # lines. 11 | AllowForAlignment: false 12 | 13 | Layout/SpaceBeforeFirstArg: 14 | Enabled: true 15 | 16 | Style/NumericLiterals: 17 | Enabled: false 18 | 19 | Metrics/BlockNesting: 20 | Max: 2 21 | 22 | Style/WordArray: 23 | Enabled: false 24 | 25 | Style/TrailingCommaInArrayLiteral: 26 | EnforcedStyleForMultiline: 'comma' 27 | 28 | Style/TrailingCommaInHashLiteral: 29 | EnforcedStyleForMultiline: 'comma' 30 | 31 | Style/TrailingCommaInArguments: 32 | EnforcedStyleForMultiline: 'comma' 33 | 34 | Style/HashSyntax: 35 | EnforcedStyle: 'ruby19' 36 | 37 | Style/StringLiterals: 38 | EnforcedStyle: double_quotes 39 | -------------------------------------------------------------------------------- /.rubocop_schema.77.yml: -------------------------------------------------------------------------------- 1 | # Configuration for Rubocop >= 0.77.0 2 | 3 | Layout/ExtraSpacing: 4 | # When true, allows most uses of extra spacing if the intent is to align 5 | # things with the previous or next line, not counting empty lines or comment 6 | # lines. 7 | AllowForAlignment: false 8 | 9 | Layout/HashAlignment: 10 | EnforcedColonStyle: 'key' 11 | EnforcedHashRocketStyle: 'key' 12 | 13 | Layout/LineLength: 14 | Enabled: false 15 | 16 | Layout/SpaceBeforeFirstArg: 17 | Enabled: true 18 | 19 | Style/NumericLiterals: 20 | Enabled: false 21 | 22 | Metrics/BlockNesting: 23 | Max: 2 24 | 25 | Style/WordArray: 26 | Enabled: false 27 | 28 | Style/TrailingCommaInArrayLiteral: 29 | EnforcedStyleForMultiline: 'comma' 30 | 31 | Style/TrailingCommaInHashLiteral: 32 | EnforcedStyleForMultiline: 'comma' 33 | 34 | Style/TrailingCommaInArguments: 35 | EnforcedStyleForMultiline: 'comma' 36 | 37 | Style/HashSyntax: 38 | EnforcedStyle: 'ruby19' 39 | 40 | Style/StringLiterals: 41 | EnforcedStyle: double_quotes 42 | -------------------------------------------------------------------------------- /.rubocop_schema.yml: -------------------------------------------------------------------------------- 1 | # Configuration for Rubocop >= 0.38.0, < 0.49.0 2 | 3 | Style/ExtraSpacing: 4 | # When true, allows most uses of extra spacing if the intent is to align 5 | # things with the previous or next line, not counting empty lines or comment 6 | # lines. 7 | AllowForAlignment: false 8 | 9 | Style/NumericLiterals: 10 | Enabled: false 11 | 12 | Style/SpaceBeforeFirstArg: 13 | Enabled: true 14 | 15 | Metrics/BlockNesting: 16 | Max: 2 17 | 18 | Style/AlignHash: 19 | EnforcedColonStyle: 'key' 20 | EnforcedHashRocketStyle: 'key' 21 | 22 | Style/WordArray: 23 | Enabled: false 24 | 25 | Style/TrailingCommaInLiteral: 26 | EnforcedStyleForMultiline: 'comma' 27 | 28 | Style/TrailingCommaInArguments: 29 | EnforcedStyleForMultiline: 'comma' 30 | 31 | Style/HashSyntax: 32 | EnforcedStyle: 'ruby19' 33 | 34 | Style/StringLiterals: 35 | EnforcedStyle: double_quotes 36 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in fix-db-schema-conflicts.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Jake Moffatt 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # fix-db-schema-conflicts 2 | 3 | It prevents db/schema.rb conflicts in your Rails projects when working with 4 | multiple team members. 5 | 6 | Specifically the situation that goes like this: 7 | 8 | John is working on a feature, and adds a migration to create an `updated_at` 9 | timestamp to `Task`. Sara is working on a different feature, and adds a 10 | migration to create a `name` column to `Task`. They both run their migrations 11 | locally, and then get a new copy of master with the other's feature and 12 | migration. Then when they run migrations again, John's `tasks` table looks like 13 | this: 14 | 15 | t.timestamp :updated_at 16 | t.string :name 17 | 18 | And Sara's looks like this: 19 | 20 | t.string :name 21 | t.timestamp :updated_at 22 | 23 | And every time they run migrations before committing new code, their 24 | `db/schema.rb` file will be showing a change, because they are flipping the 25 | order of the columns. 26 | 27 | By using the fix-db-schema-conflicts gem, this problem goes away. 28 | 29 | ## How it works 30 | 31 | This gem sorts the table, index, extension, and foreign key names before 32 | outputting them to the schema.rb file. Additionally it runs Rubocop with the 33 | auto-correct flag to ensure a consistent output format. 34 | 35 | ## Usage 36 | 37 | You don't have to do anything different. It should just work. Simply run `rake 38 | db:migrate` or `rake db:schema:dump` as you would before and 39 | `fix-db-schema-conflicts` will do the rest. 40 | 41 | ## Installation 42 | 43 | Add this line to your application's Gemfile in your development group: 44 | 45 | ```ruby 46 | gem 'fix-db-schema-conflicts' 47 | ``` 48 | 49 | And then execute: 50 | 51 | $ bundle 52 | 53 | ## Older versions of Rubocop: 54 | 55 | If you wish to use a version of Rubocop `< 0.36.0` or below, use 56 | `gem 'fix-db-schema-conflicts', '~> 1.0.2'` 57 | 58 | ## Older versions of Ruby: 59 | 60 | This gem only works with Ruby >= 2.2. Use versions 1.2.2 or below if you have an 61 | old Ruby. 62 | 63 | ## Contributing 64 | 65 | 1. Fork it (https://github.com/[my-github-username]/fix-db-schema-conflicts/fork) 66 | 2. Create your feature branch (`git checkout -b my-new-feature`) 67 | 3. Commit your changes (`git commit -am 'Add some feature'`) 68 | 4. Push to the branch (`git push origin my-new-feature`) 69 | 5. Create a new Pull Request 70 | 71 | ## Contributors 72 | 73 | - [@jakeonrails](https://github.com/jakeonrails) - Creator and maintainer 74 | - [@TCampaigne](https://github.com/TCampaigne) 75 | - [@Lordnibbler](https://github.com/Lordnibbler) 76 | - [@timdiggins](https://github.com/timdiggins) 77 | - [@zoras](https://github.com/zoras) 78 | - [@jensljungblad](https://github.com/jensljungblad) 79 | - [@vsubramanian](https://github.com/vsubramanian) 80 | - [@claytron](https://github.com/claytron) 81 | - [@amckinnell](https://github.com/amckinnell) 82 | - [@rosscooperman](https://github.com/rosscooperman) 83 | - [@cabello](https://github.com/cabello) 84 | - [@justisb](https://github.com/justisb) 85 | - [@sg650](https://github.com/sg650) 86 | 87 | ## Releases 88 | - 3.1.1 89 | - Use modern autocorrect flag for rubocop >= 1.30 (sg650) 90 | - 3.1.0 91 | - Added support for ruby 3 (cabello) 92 | - Added support for new Rubocop 0.77+ schema (justisb) 93 | - 3.0.3 94 | - Added support for new Rubocop 0.53+ schema (rosscooperman) 95 | - 3.0.2 96 | - Added support for new Rubocop 0.49+ schema (amckinnell) 97 | - 3.0.1 98 | - Improve formatting to be more consistent (amckinnell) 99 | - Bump rake dependency to bypass a rake bug in older version (amckinnell) 100 | - 3.0.0 101 | - Only support Ruby 2.2+ since lower versions haved reached EOL. 102 | - 2.0.1 103 | - Fix bug that caused failure when project directory has a space in it 104 | - 2.0.0 105 | - Allow usage of Rubocop >= 0.38.0 106 | - Remove Rails 5 deprecation warnings for using alias_method_chain 107 | - This upgrade breaks compatibility with Ruby 1.9x since 1.9x lacks #prepend 108 | - 1.2.2 109 | - Remove dependency on sed 110 | - 1.2.1 111 | - Upgrade Rubocop to get major performance boost 112 | - Add support for sorting of extensions 113 | - Fix spacing regression introduced by Rubocop upgrade 114 | - Add test suite and an integration test 115 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | 3 | 4 | begin 5 | require 'rspec/core/rake_task' 6 | RSpec::Core::RakeTask.new(:spec) 7 | rescue LoadError 8 | end 9 | 10 | task default: :spec 11 | -------------------------------------------------------------------------------- /fix-db-schema-conflicts.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'fix_db_schema_conflicts/version' 5 | 6 | Gem::Specification.new do |spec| 7 | spec.name = 'fix-db-schema-conflicts' 8 | spec.version = FixDBSchemaConflicts::VERSION 9 | spec.authors = ['Jake Moffatt'] 10 | spec.email = ['jakeonrails@gmail.com'] 11 | spec.summary = %q{Helps prevent unneeded db/schema.rb conflicts} 12 | spec.description = %q{Ensures consistent output of db/schema.rb despite local differences in the database} 13 | spec.homepage = 'https://github.com/jakeonrails/fix-db-schema-conflicts' 14 | spec.license = 'MIT' 15 | 16 | spec.files = `git ls-files -z`.split("\x0") 17 | spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } 18 | spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) 19 | spec.require_paths = ['lib'] 20 | 21 | spec.add_development_dependency 'bundler' 22 | spec.add_development_dependency 'rake' 23 | spec.add_development_dependency 'rspec', '~>3.4.0' 24 | spec.add_development_dependency 'rails', '~> 4.2.0' 25 | spec.add_development_dependency 'sqlite3', '~> 1.3.0' 26 | 27 | spec.add_dependency 'rubocop', '>= 0.38.0' 28 | 29 | spec.required_ruby_version = '>= 2.0.0', '< 4' 30 | end 31 | -------------------------------------------------------------------------------- /lib/fix-db-schema-conflicts.rb: -------------------------------------------------------------------------------- 1 | require 'fix_db_schema_conflicts/schema_dumper.rb' 2 | 3 | module FixDBSchemaConflicts 4 | require 'fix_db_schema_conflicts/railtie' if defined?(Rails) 5 | end 6 | -------------------------------------------------------------------------------- /lib/fix_db_schema_conflicts/autocorrect_configuration.rb: -------------------------------------------------------------------------------- 1 | module FixDBSchemaConflicts 2 | class AutocorrectConfiguration 3 | def self.load 4 | new.load 5 | end 6 | 7 | def load 8 | if less_than_rubocop?(49) 9 | '.rubocop_schema.yml' 10 | elsif less_than_rubocop?(53) 11 | '.rubocop_schema.49.yml' 12 | elsif less_than_rubocop?(77) 13 | '.rubocop_schema.53.yml' 14 | else 15 | '.rubocop_schema.77.yml' 16 | end 17 | end 18 | 19 | private 20 | 21 | def less_than_rubocop?(ver) 22 | Gem.loaded_specs['rubocop'].version < Gem::Version.new("0.#{ver}.0") 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /lib/fix_db_schema_conflicts/railtie.rb: -------------------------------------------------------------------------------- 1 | require 'fix-db-schema-conflicts' 2 | require 'rails' 3 | 4 | module FixDBSchemaConflicts 5 | class Railtie < Rails::Railtie 6 | railtie_name :fix_db_schema_conflicts 7 | rake_tasks do 8 | load "fix_db_schema_conflicts/tasks/db.rake" 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/fix_db_schema_conflicts/schema_dumper.rb: -------------------------------------------------------------------------------- 1 | require 'delegate' 2 | 3 | module FixDBSchemaConflicts 4 | module SchemaDumper 5 | class ConnectionWithSorting < SimpleDelegator 6 | def extensions 7 | __getobj__.extensions.sort 8 | end 9 | 10 | def columns(table) 11 | __getobj__.columns(table).sort_by(&:name) 12 | end 13 | 14 | def indexes(table) 15 | __getobj__.indexes(table).sort_by(&:name) 16 | end 17 | 18 | def foreign_keys(table) 19 | __getobj__.indexes(table).sort_by(&:name) 20 | end 21 | end 22 | 23 | def extensions(*args) 24 | with_sorting do 25 | super(*args) 26 | end 27 | end 28 | 29 | def table(*args) 30 | with_sorting do 31 | super(*args) 32 | end 33 | end 34 | 35 | def with_sorting 36 | old, @connection = @connection, ConnectionWithSorting.new(@connection) 37 | result = yield 38 | @connection = old 39 | result 40 | end 41 | end 42 | end 43 | 44 | ActiveRecord::SchemaDumper.send(:prepend, FixDBSchemaConflicts::SchemaDumper) 45 | -------------------------------------------------------------------------------- /lib/fix_db_schema_conflicts/tasks/db.rake: -------------------------------------------------------------------------------- 1 | require 'shellwords' 2 | require_relative '../autocorrect_configuration' 3 | 4 | namespace :db do 5 | namespace :schema do 6 | task :dump do 7 | puts "Dumping database schema with fix-db-schema-conflicts gem" 8 | 9 | filename = ENV['SCHEMA'] || if defined? ActiveRecord::Tasks::DatabaseTasks 10 | File.join(ActiveRecord::Tasks::DatabaseTasks.db_dir, 'schema.rb') 11 | else 12 | "#{Rails.root}/db/schema.rb" 13 | end 14 | autocorrect_config = FixDBSchemaConflicts::AutocorrectConfiguration.load 15 | rubocop_yml = File.expand_path("../../../../#{autocorrect_config}", __FILE__) 16 | auto_correct_arg = if Gem.loaded_specs['rubocop'].version >= Gem::Version.new('1.30') 17 | 'autocorrect' 18 | else 19 | 'auto-correct' 20 | end 21 | 22 | `bundle exec rubocop --#{auto_correct_arg} --config #{rubocop_yml} #{filename.shellescape}` 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /lib/fix_db_schema_conflicts/version.rb: -------------------------------------------------------------------------------- 1 | module FixDBSchemaConflicts 2 | VERSION='3.1.1' 3 | end 4 | -------------------------------------------------------------------------------- /spec/integration/integration_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | RSpec.describe 'Fix DB Schema Conflicts' do 4 | 5 | let(:expected_lines) { reference_db_schema.lines } 6 | 7 | it 'generates a sorted schema with no extra spacing' do 8 | 9 | `cd spec/test-app && rm -f db/schema.rb && rake db:migrate` 10 | 11 | generated_lines = File.readlines('spec/test-app/db/schema.rb') 12 | 13 | generated_lines.zip(expected_lines).each do |generated, expected| 14 | next if expected.nil? 15 | next if expected.start_with?('ActiveRecord::Schema.define') 16 | expect(generated).to eq(expected) 17 | end 18 | end 19 | end 20 | 21 | def reference_db_schema 22 | <<-RUBY 23 | # This file is auto-generated from the current state of the database. Instead 24 | # of editing this file, please use the migrations feature of Active Record to 25 | # incrementally modify your database, and then regenerate this schema definition. 26 | # 27 | # Note that this schema.rb definition is the authoritative source for your 28 | # database schema. If you need to create the application database on another 29 | # system, you should be using db:schema:load, not running all the migrations 30 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations 31 | # you'll amass, the slower it'll run and the greater likelihood for issues). 32 | # 33 | # It's strongly recommended that you check this file into your version control system. 34 | 35 | ActiveRecord::Schema.define(version: 20160322223258) do 36 | create_table "companies", force: :cascade do |t| 37 | t.string "addr1" 38 | t.string "addr2" 39 | t.string "city" 40 | t.datetime "created_at", null: false 41 | t.string "name" 42 | t.string "phone" 43 | t.string "state" 44 | t.datetime "updated_at", null: false 45 | t.string "zip" 46 | end 47 | 48 | add_index "companies", ["city"], name: "index_companies_on_city" 49 | add_index "companies", ["name"], name: "index_companies_on_name" 50 | add_index "companies", ["state"], name: "index_companies_on_state" 51 | 52 | create_table "people", force: :cascade do |t| 53 | t.integer "age" 54 | t.date "birthdate" 55 | t.datetime "created_at", null: false 56 | t.string "first_name" 57 | t.string "last_name" 58 | t.datetime "updated_at", null: false 59 | end 60 | RUBY 61 | end 62 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # This file was generated by the `rspec --init` command. Conventionally, all 2 | # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. 3 | # The generated `.rspec` file contains `--require spec_helper` which will cause 4 | # this file to always be loaded, without a need to explicitly require it in any 5 | # files. 6 | # 7 | # Given that it is always loaded, you are encouraged to keep this file as 8 | # light-weight as possible. Requiring heavyweight dependencies from this file 9 | # will add to the boot time of your test suite on EVERY test run, even for an 10 | # individual file that may not need all of that loaded. Instead, consider making 11 | # a separate helper file that requires the additional dependencies and performs 12 | # the additional setup, and require it from the spec files that actually need 13 | # it. 14 | # 15 | # The `.rspec` file also contains a few flags that are not defaults but that 16 | # users commonly want. 17 | # 18 | # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration 19 | RSpec.configure do |config| 20 | # rspec-expectations config goes here. You can use an alternate 21 | # assertion/expectation library such as wrong or the stdlib/minitest 22 | # assertions if you prefer. 23 | config.expect_with :rspec do |expectations| 24 | # This option will default to `true` in RSpec 4. It makes the `description` 25 | # and `failure_message` of custom matchers include text for helper methods 26 | # defined using `chain`, e.g.: 27 | # be_bigger_than(2).and_smaller_than(4).description 28 | # # => "be bigger than 2 and smaller than 4" 29 | # ...rather than: 30 | # # => "be bigger than 2" 31 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true 32 | end 33 | 34 | # rspec-mocks config goes here. You can use an alternate test double 35 | # library (such as bogus or mocha) by changing the `mock_with` option here. 36 | config.mock_with :rspec do |mocks| 37 | # Prevents you from mocking or stubbing a method that does not exist on 38 | # a real object. This is generally recommended, and will default to 39 | # `true` in RSpec 4. 40 | mocks.verify_partial_doubles = true 41 | end 42 | 43 | # The settings below are suggested to provide a good initial experience 44 | # with RSpec, but feel free to customize to your heart's content. 45 | 46 | # These two settings work together to allow you to limit a spec run 47 | # to individual examples or groups you care about by tagging them with 48 | # `:focus` metadata. When nothing is tagged with `:focus`, all examples 49 | # get run. 50 | config.filter_run :focus 51 | config.run_all_when_everything_filtered = true 52 | 53 | # Allows RSpec to persist some state between runs in order to support 54 | # the `--only-failures` and `--next-failure` CLI options. We recommend 55 | # you configure your source control system to ignore this file. 56 | # config.example_status_persistence_file_path = "spec/examples.txt" 57 | 58 | # Limits the available syntax to the non-monkey patched syntax that is 59 | # recommended. For more details, see: 60 | # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ 61 | # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ 62 | # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode 63 | config.disable_monkey_patching! 64 | 65 | # This setting enables warnings. It's recommended, but in some cases may 66 | # be too noisy due to issues in dependencies. 67 | config.warnings = true 68 | 69 | # Many RSpec users commonly either run the entire suite or an individual 70 | # file, and it's useful to allow more verbose output when running an 71 | # individual spec file. 72 | if config.files_to_run.one? 73 | # Use the documentation formatter for detailed output, 74 | # unless a formatter has already been configured 75 | # (e.g. via a command-line flag). 76 | config.default_formatter = 'doc' 77 | end 78 | 79 | # Print the 10 slowest examples and example groups at the 80 | # end of the spec run, to help surface which specs are running 81 | # particularly slow. 82 | # config.profile_examples = 10 83 | 84 | # Run specs in random order to surface order dependencies. If you find an 85 | # order dependency and want to debug it, you can fix the order by providing 86 | # the seed, which is printed after each run. 87 | # --seed 1234 88 | config.order = :random 89 | 90 | # Seed global randomization in this process using the `--seed` CLI option. 91 | # Setting this allows you to use `--seed` to deterministically reproduce 92 | # test failures related to randomization by passing the same `--seed` value 93 | # as the one that triggered the failure. 94 | Kernel.srand config.seed 95 | end 96 | -------------------------------------------------------------------------------- /spec/test-app/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile '~/.gitignore_global' 6 | 7 | # Ignore bundler config. 8 | /.bundle 9 | 10 | # Ignore the default SQLite database. 11 | /db/*.sqlite3 12 | /db/*.sqlite3-journal 13 | 14 | # Ignore all logfiles and tempfiles. 15 | /log/* 16 | !/log/.keep 17 | /tmp 18 | -------------------------------------------------------------------------------- /spec/test-app/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 4 | gem 'rails', '4.2.5.2' 5 | # Use sqlite3 as the database for Active Record 6 | gem 'sqlite3' 7 | 8 | gem 'fix-db-schema-conflicts', path: '../..' 9 | -------------------------------------------------------------------------------- /spec/test-app/Gemfile.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: ../.. 3 | specs: 4 | fix-db-schema-conflicts (1.2.0) 5 | rubocop (>= 0.36.0) 6 | 7 | GEM 8 | remote: https://rubygems.org/ 9 | specs: 10 | actionmailer (4.2.5.2) 11 | actionpack (= 4.2.5.2) 12 | actionview (= 4.2.5.2) 13 | activejob (= 4.2.5.2) 14 | mail (~> 2.5, >= 2.5.4) 15 | rails-dom-testing (~> 1.0, >= 1.0.5) 16 | actionpack (4.2.5.2) 17 | actionview (= 4.2.5.2) 18 | activesupport (= 4.2.5.2) 19 | rack (~> 1.6) 20 | rack-test (~> 0.6.2) 21 | rails-dom-testing (~> 1.0, >= 1.0.5) 22 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 23 | actionview (4.2.5.2) 24 | activesupport (= 4.2.5.2) 25 | builder (~> 3.1) 26 | erubis (~> 2.7.0) 27 | rails-dom-testing (~> 1.0, >= 1.0.5) 28 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 29 | activejob (4.2.5.2) 30 | activesupport (= 4.2.5.2) 31 | globalid (>= 0.3.0) 32 | activemodel (4.2.5.2) 33 | activesupport (= 4.2.5.2) 34 | builder (~> 3.1) 35 | activerecord (4.2.5.2) 36 | activemodel (= 4.2.5.2) 37 | activesupport (= 4.2.5.2) 38 | arel (~> 6.0) 39 | activesupport (4.2.5.2) 40 | i18n (~> 0.7) 41 | json (~> 1.7, >= 1.7.7) 42 | minitest (~> 5.1) 43 | thread_safe (~> 0.3, >= 0.3.4) 44 | tzinfo (~> 1.1) 45 | arel (6.0.3) 46 | ast (2.2.0) 47 | builder (3.2.2) 48 | concurrent-ruby (1.0.1) 49 | erubis (2.7.0) 50 | globalid (0.3.6) 51 | activesupport (>= 4.1.0) 52 | i18n (0.7.0) 53 | json (1.8.3) 54 | loofah (2.0.3) 55 | nokogiri (>= 1.5.9) 56 | mail (2.6.3) 57 | mime-types (>= 1.16, < 3) 58 | mime-types (2.99.1) 59 | mini_portile2 (2.0.0) 60 | minitest (5.8.4) 61 | nokogiri (1.6.7.2) 62 | mini_portile2 (~> 2.0.0.rc2) 63 | parser (2.3.0.6) 64 | ast (~> 2.2) 65 | powerpack (0.1.1) 66 | rack (1.6.4) 67 | rack-test (0.6.3) 68 | rack (>= 1.0) 69 | rails (4.2.5.2) 70 | actionmailer (= 4.2.5.2) 71 | actionpack (= 4.2.5.2) 72 | actionview (= 4.2.5.2) 73 | activejob (= 4.2.5.2) 74 | activemodel (= 4.2.5.2) 75 | activerecord (= 4.2.5.2) 76 | activesupport (= 4.2.5.2) 77 | bundler (>= 1.3.0, < 2.0) 78 | railties (= 4.2.5.2) 79 | sprockets-rails 80 | rails-deprecated_sanitizer (1.0.3) 81 | activesupport (>= 4.2.0.alpha) 82 | rails-dom-testing (1.0.7) 83 | activesupport (>= 4.2.0.beta, < 5.0) 84 | nokogiri (~> 1.6.0) 85 | rails-deprecated_sanitizer (>= 1.0.1) 86 | rails-html-sanitizer (1.0.3) 87 | loofah (~> 2.0) 88 | railties (4.2.5.2) 89 | actionpack (= 4.2.5.2) 90 | activesupport (= 4.2.5.2) 91 | rake (>= 0.8.7) 92 | thor (>= 0.18.1, < 2.0) 93 | rainbow (2.1.0) 94 | rake (11.1.1) 95 | rubocop (0.38.0) 96 | parser (>= 2.3.0.6, < 3.0) 97 | powerpack (~> 0.1) 98 | rainbow (>= 1.99.1, < 3.0) 99 | ruby-progressbar (~> 1.7) 100 | unicode-display_width (~> 1.0, >= 1.0.1) 101 | ruby-progressbar (1.7.5) 102 | sprockets (3.5.2) 103 | concurrent-ruby (~> 1.0) 104 | rack (> 1, < 3) 105 | sprockets-rails (3.0.4) 106 | actionpack (>= 4.0) 107 | activesupport (>= 4.0) 108 | sprockets (>= 3.0.0) 109 | sqlite3 (1.3.11) 110 | thor (0.19.1) 111 | thread_safe (0.3.5) 112 | tzinfo (1.2.2) 113 | thread_safe (~> 0.1) 114 | unicode-display_width (1.0.2) 115 | 116 | PLATFORMS 117 | ruby 118 | 119 | DEPENDENCIES 120 | fix-db-schema-conflicts! 121 | rails (= 4.2.5.2) 122 | sqlite3 123 | 124 | BUNDLED WITH 125 | 1.10.6 126 | -------------------------------------------------------------------------------- /spec/test-app/README.rdoc: -------------------------------------------------------------------------------- 1 | == README 2 | 3 | This README would normally document whatever steps are necessary to get the 4 | application up and running. 5 | 6 | Things you may want to cover: 7 | 8 | * Ruby version 9 | 10 | * System dependencies 11 | 12 | * Configuration 13 | 14 | * Database creation 15 | 16 | * Database initialization 17 | 18 | * How to run the test suite 19 | 20 | * Services (job queues, cache servers, search engines, etc.) 21 | 22 | * Deployment instructions 23 | 24 | * ... 25 | 26 | 27 | Please feel free to use a different markup language if you do not plan to run 28 | rake doc:app. 29 | -------------------------------------------------------------------------------- /spec/test-app/Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require File.expand_path('../config/application', __FILE__) 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /spec/test-app/app/assets/config/manifest.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakeonrails/fix-db-schema-conflicts/ae9135e0bb1fb142dd483f883da0064b8be17732/spec/test-app/app/assets/config/manifest.js -------------------------------------------------------------------------------- /spec/test-app/app/assets/images/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakeonrails/fix-db-schema-conflicts/ae9135e0bb1fb142dd483f883da0064b8be17732/spec/test-app/app/assets/images/.keep -------------------------------------------------------------------------------- /spec/test-app/app/assets/javascripts/application.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into application.js, which will include all the files 2 | // listed below. 3 | // 4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, 5 | // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. 6 | // 7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 8 | // compiled file. 9 | // 10 | // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details 11 | // about supported directives. 12 | // 13 | //= require jquery 14 | //= require jquery_ujs 15 | //= require turbolinks 16 | //= require_tree . 17 | -------------------------------------------------------------------------------- /spec/test-app/app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, 6 | * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the 9 | * compiled file so the styles you add here take precedence over styles defined in any styles 10 | * defined in the other CSS/SCSS files in this directory. It is generally better to create a new 11 | * file per style scope. 12 | * 13 | *= require_tree . 14 | *= require_self 15 | */ 16 | -------------------------------------------------------------------------------- /spec/test-app/app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | # Prevent CSRF attacks by raising an exception. 3 | # For APIs, you may want to use :null_session instead. 4 | protect_from_forgery with: :exception 5 | end 6 | -------------------------------------------------------------------------------- /spec/test-app/app/controllers/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakeonrails/fix-db-schema-conflicts/ae9135e0bb1fb142dd483f883da0064b8be17732/spec/test-app/app/controllers/concerns/.keep -------------------------------------------------------------------------------- /spec/test-app/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /spec/test-app/app/mailers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakeonrails/fix-db-schema-conflicts/ae9135e0bb1fb142dd483f883da0064b8be17732/spec/test-app/app/mailers/.keep -------------------------------------------------------------------------------- /spec/test-app/app/models/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakeonrails/fix-db-schema-conflicts/ae9135e0bb1fb142dd483f883da0064b8be17732/spec/test-app/app/models/.keep -------------------------------------------------------------------------------- /spec/test-app/app/models/company.rb: -------------------------------------------------------------------------------- 1 | class Company < ActiveRecord::Base 2 | end 3 | -------------------------------------------------------------------------------- /spec/test-app/app/models/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakeonrails/fix-db-schema-conflicts/ae9135e0bb1fb142dd483f883da0064b8be17732/spec/test-app/app/models/concerns/.keep -------------------------------------------------------------------------------- /spec/test-app/app/models/person.rb: -------------------------------------------------------------------------------- 1 | class Person < ActiveRecord::Base 2 | end 3 | -------------------------------------------------------------------------------- /spec/test-app/app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |You may have mistyped the address or the page may have moved.
63 |If you are the application owner check the logs for more information.
65 |Maybe you tried to change something you didn't have access to.
63 |If you are the application owner check the logs for more information.
65 |If you are the application owner check the logs for more information.
64 |