├── .gitignore ├── .rspec ├── .travis.yml ├── CHANGELOG.md ├── Gemfile ├── LICENSE.txt ├── README.md ├── Rakefile ├── bin ├── console └── setup ├── exe └── git-merge-structure-sql ├── git-merge-structure-sql.gemspec ├── lib └── git-merge-structure-sql.rb └── spec ├── fixtures ├── mysql │ ├── base │ ├── merged │ ├── ours │ └── theirs ├── postgresql │ ├── base │ ├── merged │ ├── ours │ └── theirs └── sqlite3 │ ├── base │ ├── merged │ ├── ours │ └── theirs ├── git-merge-structure-sql_spec.rb └── spec_helper.rb /.gitignore: -------------------------------------------------------------------------------- 1 | Gemfile.lock 2 | 3 | /.bundle/ 4 | /.yardoc 5 | /_yardoc/ 6 | /coverage/ 7 | /doc/ 8 | /pkg/ 9 | /spec/reports/ 10 | /tmp/ 11 | 12 | # rspec failure tracking 13 | .rspec_status 14 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --format documentation 2 | --color 3 | --require spec_helper 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | sudo: false 3 | language: ruby 4 | cache: bundler 5 | rvm: 6 | - 2.5.1 7 | before_install: gem install bundler -v 1.16.6 8 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | ## 1.0.0 (2018-11-29) 4 | 5 | - Initial release 6 | 7 | ## 1.1.0 (2018-11-30) 8 | 9 | - Add support for the latest MySQL dump format 10 | - Mention support for the SQLite3 dump format 11 | 12 | ## 1.1.1 (2021-04-28) 13 | 14 | - Fix installation when the attribute file does not exist yet 15 | 16 | ## 1.1.2 (2021-04-30) 17 | 18 | - Implemnt local installation with --install=local 19 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } 4 | 5 | # Specify your gem's dependencies in git-merge-structure-sql.gemspec 6 | gemspec 7 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018-2021 Akinori MUSHA 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # git-merge-structure-sql 2 | 3 | This is a merge driver for Git that resolves typical merge conflicts 4 | in a `db/structure.sql` file of Rails. 5 | 6 | When your project is configured with 7 | `config.active_record.schema_format = :sql`, the database schema is 8 | kept in `db/structure.sql` instead of `db/schema.rb` in the native 9 | dump format of the underlying database engine, which is not suitable 10 | for the default merge driver of Git to deal with. As a result, when 11 | you try to merge two branches you always have to resolve trivial 12 | conflicts manually if new schema migrations take place in both 13 | branches. This custom driver takes away such a pain. 14 | 15 | Currently only PostgreSQL, MySQL and SQLite3 dump formats are 16 | supported. 17 | 18 | ## Installation 19 | 20 | Run this: 21 | 22 | $ gem install git-merge-structure-sql 23 | 24 | And enable it yourself in your Git configuration, or let it do that 25 | for you by this command: 26 | 27 | $ git-merge-structure-sql --install 28 | 29 | This adds necessary settings to your `~/.gitconfig` or 30 | `$XDG_CONFIG_HOME/git/config` and the default gitattributes(5) file to 31 | enable the merge driver for structure.sql files. 32 | 33 | If you want to enable this driver only in the current git directory, 34 | run this: 35 | 36 | $ git-merge-structure-sql --install=local 37 | 38 | ## Usage 39 | 40 | Once enabled, Git should call this driver as necessary when it needs 41 | to merge changes made in structure.sql. 42 | 43 | ## History 44 | 45 | See `CHANGELOG.md` for the version history. 46 | 47 | ## Author 48 | 49 | Copyright (c) 2018-2021 Akinori MUSHA. 50 | 51 | Licensed under the 2-clause BSD license. See `LICENSE.txt` for 52 | details. 53 | 54 | Visit the [GitHub Repository](https://github.com/knu/sidetiq-timezone) 55 | for the latest information. 56 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | require "rspec/core/rake_task" 3 | 4 | RSpec::Core::RakeTask.new(:spec) 5 | 6 | task :default => :spec 7 | -------------------------------------------------------------------------------- /bin/console: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require "bundler/setup" 4 | require "git-merge-structure-sql" 5 | 6 | # You can add fixtures and/or initialization code here to make experimenting 7 | # with your gem easier. You can also use a different console, if you like. 8 | 9 | # (If you use this, don't forget to add pry to your Gemfile!) 10 | # require "pry" 11 | # Pry.start 12 | 13 | require "irb" 14 | IRB.start(__FILE__) 15 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | set -vx 5 | 6 | bundle install 7 | 8 | # Do any other automated setup that you need to do here 9 | -------------------------------------------------------------------------------- /exe/git-merge-structure-sql: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require "git-merge-structure-sql" 4 | 5 | StructureSqlMergeDriver.new.main(*ARGV) 6 | -------------------------------------------------------------------------------- /git-merge-structure-sql.gemspec: -------------------------------------------------------------------------------- 1 | 2 | lib = File.expand_path("../lib", __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require "git-merge-structure-sql" 5 | 6 | Gem::Specification.new do |spec| 7 | spec.name = "git-merge-structure-sql" 8 | spec.version = StructureSqlMergeDriver::VERSION 9 | spec.authors = ["Akinori MUSHA"] 10 | spec.email = ["knu@idaemons.org"] 11 | spec.license = "BSD-2-Clause" 12 | 13 | spec.summary = %q{git merge driver for db/structure.sql in a Rails project} 14 | spec.homepage = "https://github.com/knu/git-merge-structure-sql" 15 | 16 | if spec.respond_to?(:metadata) 17 | spec.metadata["homepage_uri"] = spec.homepage 18 | spec.metadata["source_code_uri"] = spec.homepage 19 | spec.metadata["changelog_uri"] = "https://github.com/knu/git-merge-structure-sql/blob/master/CHANGELOG.md" 20 | end 21 | 22 | # Specify which files should be added to the gem when it is released. 23 | # The `git ls-files -z` loads the files in the RubyGem that have been added into git. 24 | spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do 25 | `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } 26 | end 27 | spec.bindir = "exe" 28 | spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } 29 | spec.require_paths = ["lib"] 30 | 31 | spec.add_development_dependency "bundler", "~> 2.2" 32 | spec.add_development_dependency "rake", "~> 13.0" 33 | spec.add_development_dependency "rspec", "~> 3.0" 34 | end 35 | -------------------------------------------------------------------------------- /lib/git-merge-structure-sql.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | # 4 | # git-merge-structure-sql - git merge driver for db/structure.sql in a Rails project 5 | # 6 | # How to use: 7 | # $ git-merge-structure-sql --install 8 | # 9 | # Copyright (c) 2018-2021 Akinori MUSHA 10 | # 11 | # All rights reserved. 12 | # 13 | # Redistribution and use in source and binary forms, with or without 14 | # modification, are permitted provided that the following conditions 15 | # are met: 16 | # 1. Redistributions of source code must retain the above copyright 17 | # notice, this list of conditions and the following disclaimer. 18 | # 2. Redistributions in binary form must reproduce the above copyright 19 | # notice, this list of conditions and the following disclaimer in the 20 | # documentation and/or other materials provided with the distribution. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 23 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 26 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 | # SUCH DAMAGE. 33 | # 34 | 35 | class StructureSqlMergeDriver 36 | VERSION = '1.1.2' 37 | VARIANTS = [] 38 | 39 | module Default # This covers PostgreSQL, SQLite and newer MySQL formats. 40 | RE_VERSION = /^\('(\d+)'\)[,;]\n/ 41 | RE_VERSIONS = /^INSERT INTO (?["`])schema_migrations\k \(version\) VALUES\n\K#{RE_VERSION}+/ 42 | 43 | class << self 44 | def match?(content) 45 | RE_VERSIONS === content 46 | end 47 | 48 | def merge!(*contents) 49 | merge_versions!(*contents) 50 | end 51 | 52 | private 53 | 54 | def merge_versions!(*contents) 55 | replacement = format_versions( 56 | contents.inject([]) { |versions, content| 57 | versions | content[RE_VERSIONS].scan(RE_VERSION).flatten 58 | }.sort 59 | ) 60 | 61 | contents.each { |content| 62 | content.sub!(RE_VERSIONS, replacement) 63 | } 64 | end 65 | 66 | def format_versions(versions) 67 | versions.map { |version| "('%s')" % version }.join(",\n") << ";\n" 68 | end 69 | end 70 | 71 | VARIANTS.unshift self 72 | end 73 | 74 | module MySQL 75 | class << self 76 | RE_DUMP_TIMESTAMP = /^-- Dump completed on \K.+$/ 77 | RE_AUTO_INCREMENT_VALUE = /^\)(?= ).*\K AUTO_INCREMENT=\d+(?=.*;$)/ 78 | RE_VERSION = /^INSERT INTO schema_migrations \(version\) VALUES \('(\d+)'\);\s+/ 79 | RE_VERSIONS = /#{RE_VERSION}+/ 80 | 81 | def match?(content) 82 | /^-- MySQL dump / === content 83 | end 84 | 85 | def merge!(*contents) 86 | merge_dump_timestamps!(*contents) 87 | scrub_auto_increment_values!(*contents) 88 | merge_versions!(*contents) 89 | end 90 | 91 | private 92 | 93 | def merge_dump_timestamps!(*contents) 94 | replacement = contents.inject('') { |timestamp, content| 95 | [timestamp, *content.scan(RE_DUMP_TIMESTAMP)].max rescue '' 96 | } 97 | 98 | unless replacement.empty? 99 | contents.each { |content| 100 | content.gsub!(RE_DUMP_TIMESTAMP, replacement) 101 | } 102 | end 103 | end 104 | 105 | def scrub_auto_increment_values!(*contents) 106 | contents.each { |content| 107 | content.gsub!(RE_AUTO_INCREMENT_VALUE, '') 108 | } 109 | end 110 | 111 | def merge_versions!(*contents) 112 | replacement = format_versions( 113 | contents.inject([]) { |versions, content| 114 | versions | content.scan(RE_VERSION).flatten 115 | }.sort 116 | ) 117 | 118 | contents.each { |content| 119 | content.sub!(RE_VERSIONS, replacement) 120 | } 121 | end 122 | 123 | def format_versions(versions) 124 | versions.map { |version| "INSERT INTO schema_migrations (version) VALUES ('%s');\n\n" % version }.join 125 | end 126 | end 127 | 128 | VARIANTS.unshift self 129 | end 130 | 131 | def system!(*args) 132 | system(*args) or exit $?.exitstatus 133 | end 134 | 135 | def main(*argv) 136 | require 'optparse' 137 | require 'shellwords' 138 | 139 | myname = File.basename($0) 140 | driver_name = 'merge-structure-sql' 141 | 142 | banner = <<~EOF 143 | #{myname} - git merge driver for db/structure.sql in a Rails project #{VERSION} 144 | 145 | usage: #{myname} 146 | #{myname} --install 147 | 148 | EOF 149 | 150 | install = false 151 | 152 | opts = OptionParser.new(banner) { |opts| 153 | opts.version = VERSION 154 | opts.summary_indent = '' 155 | opts.summary_width = 24 156 | 157 | opts.on('--install[={global|local}]', 158 | "Enable this merge driver in Git (default: global)") { |val| 159 | case install = val&.to_sym || :global 160 | when :global, :local 161 | # ok 162 | else 163 | raise OptionParser::InvalidArgument, "--install=#{val}: unknown argument" 164 | end 165 | } 166 | } 167 | 168 | files = opts.order(argv) 169 | 170 | if install 171 | global = install == :global 172 | 173 | git_config = ["git", "config", *("--global" if global)] 174 | 175 | config_file = `GIT_EDITOR=echo #{git_config.shelljoin} -e 2>/dev/null`.chomp 176 | 177 | puts "#{config_file}: Adding the \"#{driver_name}\" driver definition" 178 | 179 | system!( 180 | *git_config, 181 | "merge.#{driver_name}.name", 182 | "Rails structure.sql merge driver" 183 | ) 184 | system!( 185 | *git_config, 186 | "merge.#{driver_name}.driver", 187 | "#{myname.shellescape} %A %O %B" 188 | ) 189 | 190 | attributes_file = 191 | if global 192 | filename = `git config --global core.attributesfile`.chomp 193 | 194 | if $?.success? 195 | File.expand_path(filename) 196 | else 197 | [ 198 | [File.join(ENV['XDG_CONFIG_HOME'] || '~/.config', 'git'), 'attributes'], 199 | ['~', '.gitattributes'] 200 | ].find { |dir, file| 201 | if File.directory?(File.expand_path(dir)) 202 | system!(*%W[ 203 | git config --global core.attributesfile #{File.join(dir, file)} 204 | ]) 205 | break File.expand_path(file, dir) 206 | end 207 | } or raise "don't you have home?" 208 | end 209 | else 210 | git_dir = `git rev-parse --git-dir`.chomp 211 | 212 | if $?.success? 213 | File.expand_path(File.join('info', 'attributes'), git_dir) 214 | else 215 | raise "not in a git directory" 216 | end 217 | end 218 | 219 | File.open(attributes_file, 'a+') { |f| 220 | pattern = /^\s*structure.sql\s+(?:\S+\s+)*merge=#{Regexp.quote(driver_name)}(?:\s|$)/ 221 | break if f.any? { |line| pattern === line } 222 | 223 | puts "#{attributes_file}: Registering the \"#{driver_name}\" driver for structure.sql" 224 | f.puts if f.pos > 0 225 | f.puts "structure.sql merge=#{driver_name}" 226 | } 227 | 228 | exit 229 | end 230 | 231 | unless files.size == 3 232 | STDERR.print opts.help 233 | exit 64 234 | end 235 | 236 | contents = files.map { |file| File.read(file) } 237 | 238 | sample = contents[0] 239 | if variant = VARIANTS.find { |v| v.match?(sample) } 240 | variant.merge!(*contents) 241 | 242 | files.zip(contents) do |file, content| 243 | File.write(file, content) 244 | end 245 | else 246 | STDERR.puts "#{myname}: Unsupported format; falling back to git-merge-file(1)" 247 | end 248 | 249 | exec(*%W[git merge-file -q], *files) 250 | rescue => e 251 | STDERR.puts "#{myname}: #{e.message}" 252 | exit 1 253 | end 254 | end 255 | 256 | if $0 == __FILE__ 257 | StructureSqlMergeDriver.new.main(*ARGV) 258 | end 259 | -------------------------------------------------------------------------------- /spec/fixtures/mysql/base: -------------------------------------------------------------------------------- 1 | 2 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 3 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 4 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 5 | /*!40101 SET NAMES utf8mb4 */; 6 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 7 | /*!40103 SET TIME_ZONE='+00:00' */; 8 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 9 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 10 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 11 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 12 | DROP TABLE IF EXISTS `ar_internal_metadata`; 13 | /*!40101 SET @saved_cs_client = @@character_set_client */; 14 | /*!40101 SET character_set_client = utf8 */; 15 | CREATE TABLE `ar_internal_metadata` ( 16 | `key` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, 17 | `value` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL, 18 | `created_at` datetime NOT NULL, 19 | `updated_at` datetime NOT NULL, 20 | PRIMARY KEY (`key`) 21 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; 22 | /*!40101 SET character_set_client = @saved_cs_client */; 23 | DROP TABLE IF EXISTS `schema_migrations`; 24 | /*!40101 SET @saved_cs_client = @@character_set_client */; 25 | /*!40101 SET character_set_client = utf8 */; 26 | CREATE TABLE `schema_migrations` ( 27 | `version` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, 28 | PRIMARY KEY (`version`) 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; 30 | /*!40101 SET character_set_client = @saved_cs_client */; 31 | DROP TABLE IF EXISTS `users`; 32 | /*!40101 SET @saved_cs_client = @@character_set_client */; 33 | /*!40101 SET character_set_client = utf8 */; 34 | CREATE TABLE `users` ( 35 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 36 | `name` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL, 37 | `created_at` datetime NOT NULL, 38 | `updated_at` datetime NOT NULL, 39 | PRIMARY KEY (`id`) 40 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; 41 | /*!40101 SET character_set_client = @saved_cs_client */; 42 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 43 | 44 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 45 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 46 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 47 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 48 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 49 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 50 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 51 | 52 | INSERT INTO `schema_migrations` (version) VALUES 53 | ('20181129162731'); 54 | 55 | 56 | -------------------------------------------------------------------------------- /spec/fixtures/mysql/merged: -------------------------------------------------------------------------------- 1 | 2 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 3 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 4 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 5 | /*!40101 SET NAMES utf8mb4 */; 6 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 7 | /*!40103 SET TIME_ZONE='+00:00' */; 8 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 9 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 10 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 11 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 12 | DROP TABLE IF EXISTS `ar_internal_metadata`; 13 | /*!40101 SET @saved_cs_client = @@character_set_client */; 14 | /*!40101 SET character_set_client = utf8 */; 15 | CREATE TABLE `ar_internal_metadata` ( 16 | `key` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, 17 | `value` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL, 18 | `created_at` datetime NOT NULL, 19 | `updated_at` datetime NOT NULL, 20 | PRIMARY KEY (`key`) 21 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; 22 | /*!40101 SET character_set_client = @saved_cs_client */; 23 | DROP TABLE IF EXISTS `articles`; 24 | /*!40101 SET @saved_cs_client = @@character_set_client */; 25 | /*!40101 SET character_set_client = utf8 */; 26 | CREATE TABLE `articles` ( 27 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 28 | `title` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL, 29 | `content` text COLLATE utf8mb4_bin, 30 | `created_at` datetime NOT NULL, 31 | `updated_at` datetime NOT NULL, 32 | PRIMARY KEY (`id`) 33 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; 34 | /*!40101 SET character_set_client = @saved_cs_client */; 35 | DROP TABLE IF EXISTS `schema_migrations`; 36 | /*!40101 SET @saved_cs_client = @@character_set_client */; 37 | /*!40101 SET character_set_client = utf8 */; 38 | CREATE TABLE `schema_migrations` ( 39 | `version` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, 40 | PRIMARY KEY (`version`) 41 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; 42 | /*!40101 SET character_set_client = @saved_cs_client */; 43 | DROP TABLE IF EXISTS `user_profiles`; 44 | /*!40101 SET @saved_cs_client = @@character_set_client */; 45 | /*!40101 SET character_set_client = utf8 */; 46 | CREATE TABLE `user_profiles` ( 47 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 48 | `user_id` int(11) DEFAULT NULL, 49 | `self_introduction` text COLLATE utf8mb4_bin, 50 | `created_at` datetime NOT NULL, 51 | `updated_at` datetime NOT NULL, 52 | PRIMARY KEY (`id`) 53 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; 54 | /*!40101 SET character_set_client = @saved_cs_client */; 55 | DROP TABLE IF EXISTS `users`; 56 | /*!40101 SET @saved_cs_client = @@character_set_client */; 57 | /*!40101 SET character_set_client = utf8 */; 58 | CREATE TABLE `users` ( 59 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 60 | `name` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL, 61 | `created_at` datetime NOT NULL, 62 | `updated_at` datetime NOT NULL, 63 | PRIMARY KEY (`id`) 64 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; 65 | /*!40101 SET character_set_client = @saved_cs_client */; 66 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 67 | 68 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 69 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 70 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 71 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 72 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 73 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 74 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 75 | 76 | INSERT INTO `schema_migrations` (version) VALUES 77 | ('20181129162731'), 78 | ('20181129163134'), 79 | ('20181129163626'); 80 | 81 | 82 | -------------------------------------------------------------------------------- /spec/fixtures/mysql/ours: -------------------------------------------------------------------------------- 1 | 2 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 3 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 4 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 5 | /*!40101 SET NAMES utf8mb4 */; 6 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 7 | /*!40103 SET TIME_ZONE='+00:00' */; 8 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 9 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 10 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 11 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 12 | DROP TABLE IF EXISTS `ar_internal_metadata`; 13 | /*!40101 SET @saved_cs_client = @@character_set_client */; 14 | /*!40101 SET character_set_client = utf8 */; 15 | CREATE TABLE `ar_internal_metadata` ( 16 | `key` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, 17 | `value` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL, 18 | `created_at` datetime NOT NULL, 19 | `updated_at` datetime NOT NULL, 20 | PRIMARY KEY (`key`) 21 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; 22 | /*!40101 SET character_set_client = @saved_cs_client */; 23 | DROP TABLE IF EXISTS `articles`; 24 | /*!40101 SET @saved_cs_client = @@character_set_client */; 25 | /*!40101 SET character_set_client = utf8 */; 26 | CREATE TABLE `articles` ( 27 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 28 | `title` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL, 29 | `content` text COLLATE utf8mb4_bin, 30 | `created_at` datetime NOT NULL, 31 | `updated_at` datetime NOT NULL, 32 | PRIMARY KEY (`id`) 33 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; 34 | /*!40101 SET character_set_client = @saved_cs_client */; 35 | DROP TABLE IF EXISTS `schema_migrations`; 36 | /*!40101 SET @saved_cs_client = @@character_set_client */; 37 | /*!40101 SET character_set_client = utf8 */; 38 | CREATE TABLE `schema_migrations` ( 39 | `version` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, 40 | PRIMARY KEY (`version`) 41 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; 42 | /*!40101 SET character_set_client = @saved_cs_client */; 43 | DROP TABLE IF EXISTS `users`; 44 | /*!40101 SET @saved_cs_client = @@character_set_client */; 45 | /*!40101 SET character_set_client = utf8 */; 46 | CREATE TABLE `users` ( 47 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 48 | `name` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL, 49 | `created_at` datetime NOT NULL, 50 | `updated_at` datetime NOT NULL, 51 | PRIMARY KEY (`id`) 52 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; 53 | /*!40101 SET character_set_client = @saved_cs_client */; 54 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 55 | 56 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 57 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 58 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 59 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 60 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 61 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 62 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 63 | 64 | INSERT INTO `schema_migrations` (version) VALUES 65 | ('20181129162731'), 66 | ('20181129163134'); 67 | 68 | 69 | -------------------------------------------------------------------------------- /spec/fixtures/mysql/theirs: -------------------------------------------------------------------------------- 1 | 2 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 3 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 4 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 5 | /*!40101 SET NAMES utf8mb4 */; 6 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 7 | /*!40103 SET TIME_ZONE='+00:00' */; 8 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 9 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 10 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 11 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 12 | DROP TABLE IF EXISTS `ar_internal_metadata`; 13 | /*!40101 SET @saved_cs_client = @@character_set_client */; 14 | /*!40101 SET character_set_client = utf8 */; 15 | CREATE TABLE `ar_internal_metadata` ( 16 | `key` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, 17 | `value` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL, 18 | `created_at` datetime NOT NULL, 19 | `updated_at` datetime NOT NULL, 20 | PRIMARY KEY (`key`) 21 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; 22 | /*!40101 SET character_set_client = @saved_cs_client */; 23 | DROP TABLE IF EXISTS `schema_migrations`; 24 | /*!40101 SET @saved_cs_client = @@character_set_client */; 25 | /*!40101 SET character_set_client = utf8 */; 26 | CREATE TABLE `schema_migrations` ( 27 | `version` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, 28 | PRIMARY KEY (`version`) 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; 30 | /*!40101 SET character_set_client = @saved_cs_client */; 31 | DROP TABLE IF EXISTS `user_profiles`; 32 | /*!40101 SET @saved_cs_client = @@character_set_client */; 33 | /*!40101 SET character_set_client = utf8 */; 34 | CREATE TABLE `user_profiles` ( 35 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 36 | `user_id` int(11) DEFAULT NULL, 37 | `self_introduction` text COLLATE utf8mb4_bin, 38 | `created_at` datetime NOT NULL, 39 | `updated_at` datetime NOT NULL, 40 | PRIMARY KEY (`id`) 41 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; 42 | /*!40101 SET character_set_client = @saved_cs_client */; 43 | DROP TABLE IF EXISTS `users`; 44 | /*!40101 SET @saved_cs_client = @@character_set_client */; 45 | /*!40101 SET character_set_client = utf8 */; 46 | CREATE TABLE `users` ( 47 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 48 | `name` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL, 49 | `created_at` datetime NOT NULL, 50 | `updated_at` datetime NOT NULL, 51 | PRIMARY KEY (`id`) 52 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; 53 | /*!40101 SET character_set_client = @saved_cs_client */; 54 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 55 | 56 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 57 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 58 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 59 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 60 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 61 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 62 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 63 | 64 | INSERT INTO `schema_migrations` (version) VALUES 65 | ('20181129162731'), 66 | ('20181129163626'); 67 | 68 | 69 | -------------------------------------------------------------------------------- /spec/fixtures/postgresql/base: -------------------------------------------------------------------------------- 1 | SET statement_timeout = 0; 2 | SET lock_timeout = 0; 3 | SET idle_in_transaction_session_timeout = 0; 4 | SET client_encoding = 'UTF8'; 5 | SET standard_conforming_strings = on; 6 | SELECT pg_catalog.set_config('search_path', '', false); 7 | SET check_function_bodies = false; 8 | SET client_min_messages = warning; 9 | SET row_security = off; 10 | 11 | -- 12 | -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: - 13 | -- 14 | 15 | CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; 16 | 17 | 18 | -- 19 | -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: - 20 | -- 21 | 22 | COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; 23 | 24 | 25 | SET default_tablespace = ''; 26 | 27 | SET default_with_oids = false; 28 | 29 | -- 30 | -- Name: ar_internal_metadata; Type: TABLE; Schema: public; Owner: - 31 | -- 32 | 33 | CREATE TABLE public.ar_internal_metadata ( 34 | key character varying NOT NULL, 35 | value character varying, 36 | created_at timestamp without time zone NOT NULL, 37 | updated_at timestamp without time zone NOT NULL 38 | ); 39 | 40 | 41 | -- 42 | -- Name: articles; Type: TABLE; Schema: public; Owner: - 43 | -- 44 | 45 | CREATE TABLE public.articles ( 46 | id bigint NOT NULL, 47 | title character varying, 48 | content text, 49 | created_at timestamp without time zone NOT NULL, 50 | updated_at timestamp without time zone NOT NULL 51 | ); 52 | 53 | 54 | -- 55 | -- Name: articles_id_seq; Type: SEQUENCE; Schema: public; Owner: - 56 | -- 57 | 58 | CREATE SEQUENCE public.articles_id_seq 59 | START WITH 1 60 | INCREMENT BY 1 61 | NO MINVALUE 62 | NO MAXVALUE 63 | CACHE 1; 64 | 65 | 66 | -- 67 | -- Name: articles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - 68 | -- 69 | 70 | ALTER SEQUENCE public.articles_id_seq OWNED BY public.articles.id; 71 | 72 | 73 | -- 74 | -- Name: schema_migrations; Type: TABLE; Schema: public; Owner: - 75 | -- 76 | 77 | CREATE TABLE public.schema_migrations ( 78 | version character varying NOT NULL 79 | ); 80 | 81 | 82 | -- 83 | -- Name: user_profiles; Type: TABLE; Schema: public; Owner: - 84 | -- 85 | 86 | CREATE TABLE public.user_profiles ( 87 | id bigint NOT NULL, 88 | user_id integer, 89 | self_introduction text, 90 | created_at timestamp without time zone NOT NULL, 91 | updated_at timestamp without time zone NOT NULL 92 | ); 93 | 94 | 95 | -- 96 | -- Name: user_profiles_id_seq; Type: SEQUENCE; Schema: public; Owner: - 97 | -- 98 | 99 | CREATE SEQUENCE public.user_profiles_id_seq 100 | START WITH 1 101 | INCREMENT BY 1 102 | NO MINVALUE 103 | NO MAXVALUE 104 | CACHE 1; 105 | 106 | 107 | -- 108 | -- Name: user_profiles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - 109 | -- 110 | 111 | ALTER SEQUENCE public.user_profiles_id_seq OWNED BY public.user_profiles.id; 112 | 113 | 114 | -- 115 | -- Name: users; Type: TABLE; Schema: public; Owner: - 116 | -- 117 | 118 | CREATE TABLE public.users ( 119 | id bigint NOT NULL, 120 | name character varying, 121 | created_at timestamp without time zone NOT NULL, 122 | updated_at timestamp without time zone NOT NULL 123 | ); 124 | 125 | 126 | -- 127 | -- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: - 128 | -- 129 | 130 | CREATE SEQUENCE public.users_id_seq 131 | START WITH 1 132 | INCREMENT BY 1 133 | NO MINVALUE 134 | NO MAXVALUE 135 | CACHE 1; 136 | 137 | 138 | -- 139 | -- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - 140 | -- 141 | 142 | ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id; 143 | 144 | 145 | -- 146 | -- Name: articles id; Type: DEFAULT; Schema: public; Owner: - 147 | -- 148 | 149 | ALTER TABLE ONLY public.articles ALTER COLUMN id SET DEFAULT nextval('public.articles_id_seq'::regclass); 150 | 151 | 152 | -- 153 | -- Name: user_profiles id; Type: DEFAULT; Schema: public; Owner: - 154 | -- 155 | 156 | ALTER TABLE ONLY public.user_profiles ALTER COLUMN id SET DEFAULT nextval('public.user_profiles_id_seq'::regclass); 157 | 158 | 159 | -- 160 | -- Name: users id; Type: DEFAULT; Schema: public; Owner: - 161 | -- 162 | 163 | ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass); 164 | 165 | 166 | -- 167 | -- Name: ar_internal_metadata ar_internal_metadata_pkey; Type: CONSTRAINT; Schema: public; Owner: - 168 | -- 169 | 170 | ALTER TABLE ONLY public.ar_internal_metadata 171 | ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key); 172 | 173 | 174 | -- 175 | -- Name: articles articles_pkey; Type: CONSTRAINT; Schema: public; Owner: - 176 | -- 177 | 178 | ALTER TABLE ONLY public.articles 179 | ADD CONSTRAINT articles_pkey PRIMARY KEY (id); 180 | 181 | 182 | -- 183 | -- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - 184 | -- 185 | 186 | ALTER TABLE ONLY public.schema_migrations 187 | ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version); 188 | 189 | 190 | -- 191 | -- Name: user_profiles user_profiles_pkey; Type: CONSTRAINT; Schema: public; Owner: - 192 | -- 193 | 194 | ALTER TABLE ONLY public.user_profiles 195 | ADD CONSTRAINT user_profiles_pkey PRIMARY KEY (id); 196 | 197 | 198 | -- 199 | -- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: - 200 | -- 201 | 202 | ALTER TABLE ONLY public.users 203 | ADD CONSTRAINT users_pkey PRIMARY KEY (id); 204 | 205 | 206 | -- 207 | -- PostgreSQL database dump complete 208 | -- 209 | 210 | SET search_path TO "$user", public; 211 | 212 | INSERT INTO "schema_migrations" (version) VALUES 213 | ('20181129162731'), 214 | ('20181129163134'), 215 | ('20181129163626'); 216 | 217 | 218 | -------------------------------------------------------------------------------- /spec/fixtures/postgresql/merged: -------------------------------------------------------------------------------- 1 | SET statement_timeout = 0; 2 | SET lock_timeout = 0; 3 | SET idle_in_transaction_session_timeout = 0; 4 | SET client_encoding = 'UTF8'; 5 | SET standard_conforming_strings = on; 6 | SELECT pg_catalog.set_config('search_path', '', false); 7 | SET check_function_bodies = false; 8 | SET client_min_messages = warning; 9 | SET row_security = off; 10 | 11 | -- 12 | -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: - 13 | -- 14 | 15 | CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; 16 | 17 | 18 | -- 19 | -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: - 20 | -- 21 | 22 | COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; 23 | 24 | 25 | SET default_tablespace = ''; 26 | 27 | SET default_with_oids = false; 28 | 29 | -- 30 | -- Name: ar_internal_metadata; Type: TABLE; Schema: public; Owner: - 31 | -- 32 | 33 | CREATE TABLE public.ar_internal_metadata ( 34 | key character varying NOT NULL, 35 | value character varying, 36 | created_at timestamp without time zone NOT NULL, 37 | updated_at timestamp without time zone NOT NULL 38 | ); 39 | 40 | 41 | -- 42 | -- Name: articles; Type: TABLE; Schema: public; Owner: - 43 | -- 44 | 45 | CREATE TABLE public.articles ( 46 | id bigint NOT NULL, 47 | title character varying, 48 | content text, 49 | created_at timestamp without time zone NOT NULL, 50 | updated_at timestamp without time zone NOT NULL 51 | ); 52 | 53 | 54 | -- 55 | -- Name: articles_id_seq; Type: SEQUENCE; Schema: public; Owner: - 56 | -- 57 | 58 | CREATE SEQUENCE public.articles_id_seq 59 | START WITH 1 60 | INCREMENT BY 1 61 | NO MINVALUE 62 | NO MAXVALUE 63 | CACHE 1; 64 | 65 | 66 | -- 67 | -- Name: articles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - 68 | -- 69 | 70 | ALTER SEQUENCE public.articles_id_seq OWNED BY public.articles.id; 71 | 72 | 73 | -- 74 | -- Name: schema_migrations; Type: TABLE; Schema: public; Owner: - 75 | -- 76 | 77 | CREATE TABLE public.schema_migrations ( 78 | version character varying NOT NULL 79 | ); 80 | 81 | 82 | -- 83 | -- Name: user_profiles; Type: TABLE; Schema: public; Owner: - 84 | -- 85 | 86 | CREATE TABLE public.user_profiles ( 87 | id bigint NOT NULL, 88 | user_id integer, 89 | self_introduction text, 90 | created_at timestamp without time zone NOT NULL, 91 | updated_at timestamp without time zone NOT NULL 92 | ); 93 | 94 | 95 | -- 96 | -- Name: user_profiles_id_seq; Type: SEQUENCE; Schema: public; Owner: - 97 | -- 98 | 99 | CREATE SEQUENCE public.user_profiles_id_seq 100 | START WITH 1 101 | INCREMENT BY 1 102 | NO MINVALUE 103 | NO MAXVALUE 104 | CACHE 1; 105 | 106 | 107 | -- 108 | -- Name: user_profiles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - 109 | -- 110 | 111 | ALTER SEQUENCE public.user_profiles_id_seq OWNED BY public.user_profiles.id; 112 | 113 | 114 | -- 115 | -- Name: user_ratings; Type: TABLE; Schema: public; Owner: - 116 | -- 117 | 118 | CREATE TABLE public.user_ratings ( 119 | id bigint NOT NULL, 120 | user_id integer, 121 | rating integer, 122 | created_at timestamp without time zone NOT NULL, 123 | updated_at timestamp without time zone NOT NULL 124 | ); 125 | 126 | 127 | -- 128 | -- Name: user_ratings_id_seq; Type: SEQUENCE; Schema: public; Owner: - 129 | -- 130 | 131 | CREATE SEQUENCE public.user_ratings_id_seq 132 | START WITH 1 133 | INCREMENT BY 1 134 | NO MINVALUE 135 | NO MAXVALUE 136 | CACHE 1; 137 | 138 | 139 | -- 140 | -- Name: user_ratings_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - 141 | -- 142 | 143 | ALTER SEQUENCE public.user_ratings_id_seq OWNED BY public.user_ratings.id; 144 | 145 | 146 | -- 147 | -- Name: users; Type: TABLE; Schema: public; Owner: - 148 | -- 149 | 150 | CREATE TABLE public.users ( 151 | id bigint NOT NULL, 152 | name character varying, 153 | created_at timestamp without time zone NOT NULL, 154 | updated_at timestamp without time zone NOT NULL 155 | ); 156 | 157 | 158 | -- 159 | -- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: - 160 | -- 161 | 162 | CREATE SEQUENCE public.users_id_seq 163 | START WITH 1 164 | INCREMENT BY 1 165 | NO MINVALUE 166 | NO MAXVALUE 167 | CACHE 1; 168 | 169 | 170 | -- 171 | -- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - 172 | -- 173 | 174 | ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id; 175 | 176 | 177 | -- 178 | -- Name: articles id; Type: DEFAULT; Schema: public; Owner: - 179 | -- 180 | 181 | ALTER TABLE ONLY public.articles ALTER COLUMN id SET DEFAULT nextval('public.articles_id_seq'::regclass); 182 | 183 | 184 | -- 185 | -- Name: user_profiles id; Type: DEFAULT; Schema: public; Owner: - 186 | -- 187 | 188 | ALTER TABLE ONLY public.user_profiles ALTER COLUMN id SET DEFAULT nextval('public.user_profiles_id_seq'::regclass); 189 | 190 | 191 | -- 192 | -- Name: user_ratings id; Type: DEFAULT; Schema: public; Owner: - 193 | -- 194 | 195 | ALTER TABLE ONLY public.user_ratings ALTER COLUMN id SET DEFAULT nextval('public.user_ratings_id_seq'::regclass); 196 | 197 | 198 | -- 199 | -- Name: users id; Type: DEFAULT; Schema: public; Owner: - 200 | -- 201 | 202 | ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass); 203 | 204 | 205 | -- 206 | -- Name: ar_internal_metadata ar_internal_metadata_pkey; Type: CONSTRAINT; Schema: public; Owner: - 207 | -- 208 | 209 | ALTER TABLE ONLY public.ar_internal_metadata 210 | ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key); 211 | 212 | 213 | -- 214 | -- Name: articles articles_pkey; Type: CONSTRAINT; Schema: public; Owner: - 215 | -- 216 | 217 | ALTER TABLE ONLY public.articles 218 | ADD CONSTRAINT articles_pkey PRIMARY KEY (id); 219 | 220 | 221 | -- 222 | -- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - 223 | -- 224 | 225 | ALTER TABLE ONLY public.schema_migrations 226 | ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version); 227 | 228 | 229 | -- 230 | -- Name: user_profiles user_profiles_pkey; Type: CONSTRAINT; Schema: public; Owner: - 231 | -- 232 | 233 | ALTER TABLE ONLY public.user_profiles 234 | ADD CONSTRAINT user_profiles_pkey PRIMARY KEY (id); 235 | 236 | 237 | -- 238 | -- Name: user_ratings user_ratings_pkey; Type: CONSTRAINT; Schema: public; Owner: - 239 | -- 240 | 241 | ALTER TABLE ONLY public.user_ratings 242 | ADD CONSTRAINT user_ratings_pkey PRIMARY KEY (id); 243 | 244 | 245 | -- 246 | -- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: - 247 | -- 248 | 249 | ALTER TABLE ONLY public.users 250 | ADD CONSTRAINT users_pkey PRIMARY KEY (id); 251 | 252 | 253 | -- 254 | -- PostgreSQL database dump complete 255 | -- 256 | 257 | SET search_path TO "$user", public; 258 | 259 | INSERT INTO "schema_migrations" (version) VALUES 260 | ('20181129162731'), 261 | ('20181129163134'), 262 | ('20181129163626'), 263 | ('20181130040309'); 264 | 265 | 266 | -------------------------------------------------------------------------------- /spec/fixtures/postgresql/ours: -------------------------------------------------------------------------------- 1 | SET statement_timeout = 0; 2 | SET lock_timeout = 0; 3 | SET idle_in_transaction_session_timeout = 0; 4 | SET client_encoding = 'UTF8'; 5 | SET standard_conforming_strings = on; 6 | SELECT pg_catalog.set_config('search_path', '', false); 7 | SET check_function_bodies = false; 8 | SET client_min_messages = warning; 9 | SET row_security = off; 10 | 11 | -- 12 | -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: - 13 | -- 14 | 15 | CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; 16 | 17 | 18 | -- 19 | -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: - 20 | -- 21 | 22 | COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; 23 | 24 | 25 | SET default_tablespace = ''; 26 | 27 | SET default_with_oids = false; 28 | 29 | -- 30 | -- Name: ar_internal_metadata; Type: TABLE; Schema: public; Owner: - 31 | -- 32 | 33 | CREATE TABLE public.ar_internal_metadata ( 34 | key character varying NOT NULL, 35 | value character varying, 36 | created_at timestamp without time zone NOT NULL, 37 | updated_at timestamp without time zone NOT NULL 38 | ); 39 | 40 | 41 | -- 42 | -- Name: articles; Type: TABLE; Schema: public; Owner: - 43 | -- 44 | 45 | CREATE TABLE public.articles ( 46 | id bigint NOT NULL, 47 | title character varying, 48 | content text, 49 | created_at timestamp without time zone NOT NULL, 50 | updated_at timestamp without time zone NOT NULL 51 | ); 52 | 53 | 54 | -- 55 | -- Name: articles_id_seq; Type: SEQUENCE; Schema: public; Owner: - 56 | -- 57 | 58 | CREATE SEQUENCE public.articles_id_seq 59 | START WITH 1 60 | INCREMENT BY 1 61 | NO MINVALUE 62 | NO MAXVALUE 63 | CACHE 1; 64 | 65 | 66 | -- 67 | -- Name: articles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - 68 | -- 69 | 70 | ALTER SEQUENCE public.articles_id_seq OWNED BY public.articles.id; 71 | 72 | 73 | -- 74 | -- Name: schema_migrations; Type: TABLE; Schema: public; Owner: - 75 | -- 76 | 77 | CREATE TABLE public.schema_migrations ( 78 | version character varying NOT NULL 79 | ); 80 | 81 | 82 | -- 83 | -- Name: user_profiles; Type: TABLE; Schema: public; Owner: - 84 | -- 85 | 86 | CREATE TABLE public.user_profiles ( 87 | id bigint NOT NULL, 88 | user_id integer, 89 | self_introduction text, 90 | created_at timestamp without time zone NOT NULL, 91 | updated_at timestamp without time zone NOT NULL 92 | ); 93 | 94 | 95 | -- 96 | -- Name: user_profiles_id_seq; Type: SEQUENCE; Schema: public; Owner: - 97 | -- 98 | 99 | CREATE SEQUENCE public.user_profiles_id_seq 100 | START WITH 1 101 | INCREMENT BY 1 102 | NO MINVALUE 103 | NO MAXVALUE 104 | CACHE 1; 105 | 106 | 107 | -- 108 | -- Name: user_profiles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - 109 | -- 110 | 111 | ALTER SEQUENCE public.user_profiles_id_seq OWNED BY public.user_profiles.id; 112 | 113 | 114 | -- 115 | -- Name: users; Type: TABLE; Schema: public; Owner: - 116 | -- 117 | 118 | CREATE TABLE public.users ( 119 | id bigint NOT NULL, 120 | name character varying, 121 | created_at timestamp without time zone NOT NULL, 122 | updated_at timestamp without time zone NOT NULL 123 | ); 124 | 125 | 126 | -- 127 | -- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: - 128 | -- 129 | 130 | CREATE SEQUENCE public.users_id_seq 131 | START WITH 1 132 | INCREMENT BY 1 133 | NO MINVALUE 134 | NO MAXVALUE 135 | CACHE 1; 136 | 137 | 138 | -- 139 | -- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - 140 | -- 141 | 142 | ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id; 143 | 144 | 145 | -- 146 | -- Name: articles id; Type: DEFAULT; Schema: public; Owner: - 147 | -- 148 | 149 | ALTER TABLE ONLY public.articles ALTER COLUMN id SET DEFAULT nextval('public.articles_id_seq'::regclass); 150 | 151 | 152 | -- 153 | -- Name: user_profiles id; Type: DEFAULT; Schema: public; Owner: - 154 | -- 155 | 156 | ALTER TABLE ONLY public.user_profiles ALTER COLUMN id SET DEFAULT nextval('public.user_profiles_id_seq'::regclass); 157 | 158 | 159 | -- 160 | -- Name: users id; Type: DEFAULT; Schema: public; Owner: - 161 | -- 162 | 163 | ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass); 164 | 165 | 166 | -- 167 | -- Name: ar_internal_metadata ar_internal_metadata_pkey; Type: CONSTRAINT; Schema: public; Owner: - 168 | -- 169 | 170 | ALTER TABLE ONLY public.ar_internal_metadata 171 | ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key); 172 | 173 | 174 | -- 175 | -- Name: articles articles_pkey; Type: CONSTRAINT; Schema: public; Owner: - 176 | -- 177 | 178 | ALTER TABLE ONLY public.articles 179 | ADD CONSTRAINT articles_pkey PRIMARY KEY (id); 180 | 181 | 182 | -- 183 | -- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - 184 | -- 185 | 186 | ALTER TABLE ONLY public.schema_migrations 187 | ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version); 188 | 189 | 190 | -- 191 | -- Name: user_profiles user_profiles_pkey; Type: CONSTRAINT; Schema: public; Owner: - 192 | -- 193 | 194 | ALTER TABLE ONLY public.user_profiles 195 | ADD CONSTRAINT user_profiles_pkey PRIMARY KEY (id); 196 | 197 | 198 | -- 199 | -- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: - 200 | -- 201 | 202 | ALTER TABLE ONLY public.users 203 | ADD CONSTRAINT users_pkey PRIMARY KEY (id); 204 | 205 | 206 | -- 207 | -- PostgreSQL database dump complete 208 | -- 209 | 210 | SET search_path TO "$user", public; 211 | 212 | INSERT INTO "schema_migrations" (version) VALUES 213 | ('20181129162731'), 214 | ('20181129163134'), 215 | ('20181129163626'); 216 | 217 | 218 | -------------------------------------------------------------------------------- /spec/fixtures/postgresql/theirs: -------------------------------------------------------------------------------- 1 | SET statement_timeout = 0; 2 | SET lock_timeout = 0; 3 | SET idle_in_transaction_session_timeout = 0; 4 | SET client_encoding = 'UTF8'; 5 | SET standard_conforming_strings = on; 6 | SELECT pg_catalog.set_config('search_path', '', false); 7 | SET check_function_bodies = false; 8 | SET client_min_messages = warning; 9 | SET row_security = off; 10 | 11 | -- 12 | -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: - 13 | -- 14 | 15 | CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; 16 | 17 | 18 | -- 19 | -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: - 20 | -- 21 | 22 | COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; 23 | 24 | 25 | SET default_tablespace = ''; 26 | 27 | SET default_with_oids = false; 28 | 29 | -- 30 | -- Name: ar_internal_metadata; Type: TABLE; Schema: public; Owner: - 31 | -- 32 | 33 | CREATE TABLE public.ar_internal_metadata ( 34 | key character varying NOT NULL, 35 | value character varying, 36 | created_at timestamp without time zone NOT NULL, 37 | updated_at timestamp without time zone NOT NULL 38 | ); 39 | 40 | 41 | -- 42 | -- Name: articles; Type: TABLE; Schema: public; Owner: - 43 | -- 44 | 45 | CREATE TABLE public.articles ( 46 | id bigint NOT NULL, 47 | title character varying, 48 | content text, 49 | created_at timestamp without time zone NOT NULL, 50 | updated_at timestamp without time zone NOT NULL 51 | ); 52 | 53 | 54 | -- 55 | -- Name: articles_id_seq; Type: SEQUENCE; Schema: public; Owner: - 56 | -- 57 | 58 | CREATE SEQUENCE public.articles_id_seq 59 | START WITH 1 60 | INCREMENT BY 1 61 | NO MINVALUE 62 | NO MAXVALUE 63 | CACHE 1; 64 | 65 | 66 | -- 67 | -- Name: articles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - 68 | -- 69 | 70 | ALTER SEQUENCE public.articles_id_seq OWNED BY public.articles.id; 71 | 72 | 73 | -- 74 | -- Name: schema_migrations; Type: TABLE; Schema: public; Owner: - 75 | -- 76 | 77 | CREATE TABLE public.schema_migrations ( 78 | version character varying NOT NULL 79 | ); 80 | 81 | 82 | -- 83 | -- Name: user_profiles; Type: TABLE; Schema: public; Owner: - 84 | -- 85 | 86 | CREATE TABLE public.user_profiles ( 87 | id bigint NOT NULL, 88 | user_id integer, 89 | self_introduction text, 90 | created_at timestamp without time zone NOT NULL, 91 | updated_at timestamp without time zone NOT NULL 92 | ); 93 | 94 | 95 | -- 96 | -- Name: user_profiles_id_seq; Type: SEQUENCE; Schema: public; Owner: - 97 | -- 98 | 99 | CREATE SEQUENCE public.user_profiles_id_seq 100 | START WITH 1 101 | INCREMENT BY 1 102 | NO MINVALUE 103 | NO MAXVALUE 104 | CACHE 1; 105 | 106 | 107 | -- 108 | -- Name: user_profiles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - 109 | -- 110 | 111 | ALTER SEQUENCE public.user_profiles_id_seq OWNED BY public.user_profiles.id; 112 | 113 | 114 | -- 115 | -- Name: user_ratings; Type: TABLE; Schema: public; Owner: - 116 | -- 117 | 118 | CREATE TABLE public.user_ratings ( 119 | id bigint NOT NULL, 120 | user_id integer, 121 | rating integer, 122 | created_at timestamp without time zone NOT NULL, 123 | updated_at timestamp without time zone NOT NULL 124 | ); 125 | 126 | 127 | -- 128 | -- Name: user_ratings_id_seq; Type: SEQUENCE; Schema: public; Owner: - 129 | -- 130 | 131 | CREATE SEQUENCE public.user_ratings_id_seq 132 | START WITH 1 133 | INCREMENT BY 1 134 | NO MINVALUE 135 | NO MAXVALUE 136 | CACHE 1; 137 | 138 | 139 | -- 140 | -- Name: user_ratings_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - 141 | -- 142 | 143 | ALTER SEQUENCE public.user_ratings_id_seq OWNED BY public.user_ratings.id; 144 | 145 | 146 | -- 147 | -- Name: users; Type: TABLE; Schema: public; Owner: - 148 | -- 149 | 150 | CREATE TABLE public.users ( 151 | id bigint NOT NULL, 152 | name character varying, 153 | created_at timestamp without time zone NOT NULL, 154 | updated_at timestamp without time zone NOT NULL 155 | ); 156 | 157 | 158 | -- 159 | -- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: - 160 | -- 161 | 162 | CREATE SEQUENCE public.users_id_seq 163 | START WITH 1 164 | INCREMENT BY 1 165 | NO MINVALUE 166 | NO MAXVALUE 167 | CACHE 1; 168 | 169 | 170 | -- 171 | -- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - 172 | -- 173 | 174 | ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id; 175 | 176 | 177 | -- 178 | -- Name: articles id; Type: DEFAULT; Schema: public; Owner: - 179 | -- 180 | 181 | ALTER TABLE ONLY public.articles ALTER COLUMN id SET DEFAULT nextval('public.articles_id_seq'::regclass); 182 | 183 | 184 | -- 185 | -- Name: user_profiles id; Type: DEFAULT; Schema: public; Owner: - 186 | -- 187 | 188 | ALTER TABLE ONLY public.user_profiles ALTER COLUMN id SET DEFAULT nextval('public.user_profiles_id_seq'::regclass); 189 | 190 | 191 | -- 192 | -- Name: user_ratings id; Type: DEFAULT; Schema: public; Owner: - 193 | -- 194 | 195 | ALTER TABLE ONLY public.user_ratings ALTER COLUMN id SET DEFAULT nextval('public.user_ratings_id_seq'::regclass); 196 | 197 | 198 | -- 199 | -- Name: users id; Type: DEFAULT; Schema: public; Owner: - 200 | -- 201 | 202 | ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass); 203 | 204 | 205 | -- 206 | -- Name: ar_internal_metadata ar_internal_metadata_pkey; Type: CONSTRAINT; Schema: public; Owner: - 207 | -- 208 | 209 | ALTER TABLE ONLY public.ar_internal_metadata 210 | ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key); 211 | 212 | 213 | -- 214 | -- Name: articles articles_pkey; Type: CONSTRAINT; Schema: public; Owner: - 215 | -- 216 | 217 | ALTER TABLE ONLY public.articles 218 | ADD CONSTRAINT articles_pkey PRIMARY KEY (id); 219 | 220 | 221 | -- 222 | -- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - 223 | -- 224 | 225 | ALTER TABLE ONLY public.schema_migrations 226 | ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version); 227 | 228 | 229 | -- 230 | -- Name: user_profiles user_profiles_pkey; Type: CONSTRAINT; Schema: public; Owner: - 231 | -- 232 | 233 | ALTER TABLE ONLY public.user_profiles 234 | ADD CONSTRAINT user_profiles_pkey PRIMARY KEY (id); 235 | 236 | 237 | -- 238 | -- Name: user_ratings user_ratings_pkey; Type: CONSTRAINT; Schema: public; Owner: - 239 | -- 240 | 241 | ALTER TABLE ONLY public.user_ratings 242 | ADD CONSTRAINT user_ratings_pkey PRIMARY KEY (id); 243 | 244 | 245 | -- 246 | -- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: - 247 | -- 248 | 249 | ALTER TABLE ONLY public.users 250 | ADD CONSTRAINT users_pkey PRIMARY KEY (id); 251 | 252 | 253 | -- 254 | -- PostgreSQL database dump complete 255 | -- 256 | 257 | SET search_path TO "$user", public; 258 | 259 | INSERT INTO "schema_migrations" (version) VALUES 260 | ('20181129162731'), 261 | ('20181129163134'), 262 | ('20181129163626'), 263 | ('20181130040309'); 264 | 265 | 266 | -------------------------------------------------------------------------------- /spec/fixtures/sqlite3/base: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY); 2 | CREATE TABLE IF NOT EXISTS "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); 3 | CREATE TABLE IF NOT EXISTS "users" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); 4 | CREATE TABLE sqlite_sequence(name,seq); 5 | INSERT INTO "schema_migrations" (version) VALUES 6 | ('20181129162731'); 7 | 8 | 9 | -------------------------------------------------------------------------------- /spec/fixtures/sqlite3/merged: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY); 2 | CREATE TABLE IF NOT EXISTS "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); 3 | CREATE TABLE IF NOT EXISTS "articles" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar, "content" text, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); 4 | CREATE TABLE IF NOT EXISTS "users" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); 5 | CREATE TABLE sqlite_sequence(name,seq); 6 | CREATE TABLE IF NOT EXISTS "user_profiles" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" integer, "self_introduction" text, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); 7 | INSERT INTO "schema_migrations" (version) VALUES 8 | ('20181129162731'), 9 | ('20181129163134'), 10 | ('20181129163626'); 11 | 12 | 13 | -------------------------------------------------------------------------------- /spec/fixtures/sqlite3/ours: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY); 2 | CREATE TABLE IF NOT EXISTS "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); 3 | CREATE TABLE IF NOT EXISTS "articles" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar, "content" text, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); 4 | CREATE TABLE IF NOT EXISTS "users" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); 5 | CREATE TABLE sqlite_sequence(name,seq); 6 | INSERT INTO "schema_migrations" (version) VALUES 7 | ('20181129162731'), 8 | ('20181129163134'); 9 | 10 | 11 | -------------------------------------------------------------------------------- /spec/fixtures/sqlite3/theirs: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY); 2 | CREATE TABLE IF NOT EXISTS "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); 3 | CREATE TABLE IF NOT EXISTS "users" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); 4 | CREATE TABLE sqlite_sequence(name,seq); 5 | CREATE TABLE IF NOT EXISTS "user_profiles" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" integer, "self_introduction" text, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); 6 | INSERT INTO "schema_migrations" (version) VALUES 7 | ('20181129162731'), 8 | ('20181129163626'); 9 | 10 | 11 | -------------------------------------------------------------------------------- /spec/git-merge-structure-sql_spec.rb: -------------------------------------------------------------------------------- 1 | require 'fileutils' 2 | require 'tmpdir' 3 | 4 | RSpec.describe StructureSqlMergeDriver do 5 | it "has a version number" do 6 | expect(StructureSqlMergeDriver::VERSION).not_to be nil 7 | end 8 | 9 | def test_merge(name) 10 | files_dir = File.realdirpath("fixtures/#{name}", __dir__) 11 | Dir.mktmpdir { |dir| 12 | FileUtils.cp( 13 | [ 14 | File.join(files_dir, 'ours'), 15 | File.join(files_dir, 'base'), 16 | File.join(files_dir, 'theirs') 17 | ], 18 | dir 19 | ) 20 | 21 | expect( 22 | system( 23 | File.realpath('../exe/git-merge-structure-sql', __dir__), 24 | File.join(dir, 'ours'), 25 | File.join(dir, 'base'), 26 | File.join(dir, 'theirs') 27 | ) 28 | ).to eq true 29 | 30 | expect( 31 | File.read(File.join(dir, 'ours')) 32 | ).to eq File.read(File.join(files_dir, 'merged')) 33 | } 34 | end 35 | 36 | it "merges SQLite3 dump files" do 37 | test_merge('sqlite3') 38 | end 39 | 40 | it "merges newer MySQL dump files" do 41 | test_merge('mysql') 42 | end 43 | 44 | it "merges PostgreSQL dump files" do 45 | test_merge('postgresql') 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require "bundler/setup" 2 | require "git-merge-structure-sql" 3 | 4 | RSpec.configure do |config| 5 | # Enable flags like --only-failures and --next-failure 6 | config.example_status_persistence_file_path = ".rspec_status" 7 | 8 | # Disable RSpec exposing methods globally on `Module` and `main` 9 | config.disable_monkey_patching! 10 | 11 | config.expect_with :rspec do |c| 12 | c.syntax = :expect 13 | end 14 | end 15 | --------------------------------------------------------------------------------